logo
Loading...

mean_df.columns = [c, f'{c}_mean']程式問題 - Cupoy

for c in df.columns:    mean_df = data.groupby([c]...

mean_df.columns = [c, f'{c}_mean']程式問題

2020/03/30 03:28 PM
機器學習新手論壇
Morgan Lin
觀看數:0
回答數:2
收藏數:0

for c in df.columns:

    mean_df = data.groupby([c])['SalePrice'].mean().reset_index()

    mean_df.columns = [c, f'{c}_mean']

    data = pd.merge(data, mean_df, on=c, how='left')

    data = data.drop([c] , axis=1)

這個for 迴圈的部分看不太懂