在数据框中,我有这些列['Happiness score', 'GDP', 'country name', 'Region']
,我必须创建所有地区的列表,对于每个地区,我必须找到最大值每列并命名相应的国家/地区,我已经将区域放入np.unique(df['Region'])
,但是我该如何进行?
使用groupby
:
df.groupby('Region').max('GDP')['GDP']
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.