Python Forum
Python Pandas: How do I average ONLY the data >1000 from several columns? - Printable Version

+- Python Forum (https://python-forum.io)
+-- Forum: Python Coding (https://python-forum.io/forum-7.html)
+--- Forum: General Coding Help (https://python-forum.io/forum-8.html)
+--- Thread: Python Pandas: How do I average ONLY the data >1000 from several columns? (/thread-34309.html)



Python Pandas: How do I average ONLY the data >1000 from several columns? - JaneTan - Jul-17-2021

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