如何找到最大化数据框中列的行?
How to find the row that maximize a column in a dataframe?
我有三个数据框:london_working_hours
、asian_london_table
、london_table_earning
,其中有一个与自治市镇名称对应的公共列。
我想得到工作价值最高的行政区名称,然后得到该行政区的人口和每小时收入
print("The highest borough in working hours , asian population and earning per hour is : ???")
这段代码给了我这个结果
最后一张印刷品应该给我亚洲人口工作时间最长和每小时收入最高的自治市镇名称,我该怎么做?
编辑:
您可以在评论中找到 link 到我的 github 了解更多详情
我想你想这样做:
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]
我有三个数据框:london_working_hours
、asian_london_table
、london_table_earning
,其中有一个与自治市镇名称对应的公共列。
我想得到工作价值最高的行政区名称,然后得到该行政区的人口和每小时收入
print("The highest borough in working hours , asian population and earning per hour is : ???")
这段代码给了我这个结果
编辑:
您可以在评论中找到 link 到我的 github 了解更多详情
我想你想这样做:
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]