簡體   English   中英

如何找到最大化數據框中列的行?

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

我有三個數據框: london_working_hoursasian_london_tablelondon_table_earning ,它們有一個與行政區名稱相對應的 common 列。

我想獲得具有最高工作價值的行政區名稱,然后獲得該行政區的人口和每小時收入

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

這段代碼給了我這個結果在此處輸入圖片說明 最后一張應該給我一個自治市鎮的名字,它在亞洲人口中的工作時間和每小時收入最高,我該怎么做??

編輯 :

您可以在評論中找到指向我的 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]

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM