Python Forum
Referring to a specific element in Pandas Dataframe
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Referring to a specific element in Pandas Dataframe
#2
You can use .iloc to get specific elements, e.g. in last column of the data frame.

df.iloc[1, -1] will return element in the last column that belongs to the second row (0-based indexing in pandas).

If you need to calculate average salaries per industry, you need to look at grouping facilities of pandas, e.g. df.groupby(['industry'])['salary'].mean(). This assumes the df has salary and industry columns.

Hope that helps...
Reply


Messages In This Thread
RE: Referring to a specific element in Pandas Dataframe - by scidam - Mar-16-2019, 12:50 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  Add NER output to pandas dataframe dg3000 0 152 Apr-22-2024, 08:14 PM
Last Post: dg3000
  HTML Decoder pandas dataframe column mbrown009 3 1,065 Sep-29-2023, 05:56 PM
Last Post: deanhystad
  Use pandas to obtain cartesian product between a dataframe of int and equations? haihal 0 1,136 Jan-06-2023, 10:53 PM
Last Post: haihal
  Pandas Dataframe Filtering based on rows mvdlm 0 1,453 Apr-02-2022, 06:39 PM
Last Post: mvdlm
  Pandas dataframe: calculate metrics by year mcva 1 2,339 Mar-02-2022, 08:22 AM
Last Post: mcva
  Pandas dataframe comparing anto5 0 1,279 Jan-30-2022, 10:21 AM
Last Post: anto5
  PANDAS: DataFrame | Replace and others questions moduki1 2 1,818 Jan-10-2022, 07:19 PM
Last Post: moduki1
  PANDAS: DataFrame | Saving the wrong value moduki1 0 1,568 Jan-10-2022, 04:42 PM
Last Post: moduki1
  Remove specific values from dataframe jonah88888 0 1,725 Sep-24-2021, 05:09 AM
Last Post: jonah88888
  update values in one dataframe based on another dataframe - Pandas iliasb 2 9,332 Aug-14-2021, 12:38 PM
Last Post: jefsummers

Forum Jump:

User Panel Messages

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