logo
Loading...

groupby 問題 - Cupoy

#2-1範例程式grp = ['CNT_CHILDREN_GROUP', 'TARGET']grou...

ml100-4,ml100-4-d13

groupby 問題

2020/03/15 04:11 AM
機器學習新手論壇
Shih Cheng Chen
觀看數:0
回答數:2
收藏數:0
ml100-4
ml100-4-d13

#2-1範例程式

grp = ['CNT_CHILDREN_GROUP', 'TARGET']
grouped_df
= app_train.groupby(grp)['AMT_INCOME_TOTAL']
grouped_df
.mean()


為什麼不能寫成這樣

grp = ['CNT_CHILDREN_GROUP', 'TARGET']

grouped_df = app_train['AMT_INCOME_TOTAL'].groupby(grp

grouped_df.mean()

#執行後出現KeyError: 'CNT_CHILDREN_GROUP'