Python Forum
Python Pandas: How do I average ONLY the data >1000 from several columns?
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Python Pandas: How do I average ONLY the data >1000 from several columns?
#1
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
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  How do I calculate a ratio from 2 numbers and return an equivalent list of about 1000 Pleiades 8 15,630 Jan-05-2024, 08:30 PM
Last Post: sgrey
  Better python library to create ER Diagram by using pandas data frames as tables klllmmm 0 1,097 Oct-19-2023, 01:01 PM
Last Post: klllmmm
  Using pyodbc&pandas to load a Table data to df tester_V 3 796 Sep-09-2023, 08:55 PM
Last Post: tester_V
  Extracting Data into Columns using pdfplumber arvin 17 5,501 Dec-17-2022, 11:59 AM
Last Post: arvin
  How to properly format rows and columns in excel data from parsed .txt blocks jh67 7 1,872 Dec-12-2022, 08:22 PM
Last Post: jh67
  How to keep columns header on excel without change after export data to excel file? ahmedbarbary 0 1,159 May-03-2022, 05:46 PM
Last Post: ahmedbarbary
  Move a particular row in pandas data frame to last row klllmmm 0 3,745 Dec-27-2021, 09:11 AM
Last Post: klllmmm
  Sum the values in a pandas pivot table specific columns klllmmm 1 4,621 Nov-19-2021, 04:43 PM
Last Post: klllmmm
  Found input variables with inconsistent numbers of samples: [1000, 200] jenya56 2 2,871 Sep-15-2021, 12:48 PM
Last Post: jenya56
  Python Pandas: How do I extract all the >1000 data from a certain column? JaneTan 0 1,555 Jul-17-2021, 09:09 AM
Last Post: JaneTan

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020