Python Forum

Full Version: Python Pandas: How do I average ONLY the data >1000 from several columns?
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
I am new to pandas. I just want to average the revenue from Revenue1 to Revenue3 that are > 1000. The dataframe will have other numerical columns like Income. Thank you!

Input:

|Name | Revenue1| Revenue2| Revenue3| Income |
|Peter| 1000 | 2000 | 3000 | 100 |
|Jane | 9000 | 10000 | 5000 | 200 |

Desired Output:

| Name | Average |
| Peter | 2500 |
| Jane | 8000 |

Peter =average (2000+ 3000) = 2500
Jane =average (9000+ 10000 +5000) = 8000