Python Forum

Full Version: Python Pandas: How do I extract all the >1000 data from a certain column?
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Hi

I am new to pandas. For Revenue, I just want to extract all Revenue !>1000, and sum all the extracted data.

**Input:**

`
|Name | Revenue|
|Peter| 10000 |
|Jane | 20000 |
|Sally| 30000 |
`

**Output:**


`
| Revenue|
| 20000 |
| 30000 |

Ans=2000+ 30000 = 5000
`

Currently, I can obtain the results with the below code. But is there a more elegant way of doing it? Sorry if the query is simple. I am still learning pandas. Thank you

table3=table1[(table1['Revenue'] >1000)]
table3['Revenue'].sum(axis=0)