Hazem
Hazem

Reputation: 141

How to find the row that maximize a column in a dataframe?

I have Three data frames : london_working_hours, asian_london_table,london_table_earning which have a column common who correspond to the borough name.

I would like to get the borough name which have the highest working value then get the population and the earning per hour of this borough

print("The highest borough in working hours , asian population and earning per hour is : ???")

this code gives me this result enter image description here The last print should give me the Borough name which have the highest working hours with asian population and earning per hour how can I do that??

Edit :

You can find in the comment the link to my github for more details

Upvotes: 1

Views: 73

Answers (1)

Omar Aldakar
Omar Aldakar

Reputation: 545

I think you want to do this :

most_working_borough = london_working_hours.sort_values(by='Working Hours%', ascending=False).Boroughs.tolist()[0]
population = asian_london_table.loc[asian_london_table['Area'] == most_working_borough].Area.tolist()[0]
earning = london_table_earning.loc[london_table_earning['Area'] == most_working_borough].Area.tolist()[0]

Upvotes: 1

Related Questions