我有三个数据框:london_working_hours
、asian_london_table
和london_table_earning
,它们都有一个共同的列,对应于伦敦各区的名称。
我想找到工作时间最高的区,然后获取该区的人口和每小时收入。
print("工作时间最长、亚洲人口最多且每小时收入最高的区是:???")
这段代码给我这样的结果 最后的打印应该显示出工作时间最长且有亚洲人口和每小时收入的区名,我该怎么做呢?
编辑:
您可以在评论中找到我的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]