Pandas SettingWithCopyWarning: A value is trying to be set on a copy of a slice from a DataFrame

前端 未结 2 409
攒了一身酷
攒了一身酷 2021-01-11 22:25

I keep getting the warning in the subject in the following situations:

  1. df.rename(columns={\'one\':\'one_a\'}, inplace=True)

  2. df.drop([\'one\'

2条回答
  •  迷失自我
    2021-01-11 22:46

    Easiest fix (and probably good programming practice) would be to not do inplace operations, e.g.

    df2 = df.rename(columns={'one':'one_a'})
    

提交回复
热议问题