之前一直在写
df['coloumn'] = df['coloumn'].apply(lambda x: (x - MIN) / (MAX - MIN))
但是系统一直报错。
SettingWithCopyWarning:
A value is trying to be set on a copy of a slice from a DataFrame.
Try using .loc[row_indexer,col_indexer] = value instead
See the caveats in the documentation: http://pandas.pydata.org/pandas-docs/stable/indexing.html#indexing-view-versus-copy
df['coloumn'] = df['coloumn'].apply(lambda x: (x - MIN) / (MAX - MIN))
真的令人头疼。
解决方法其实很简单,就是将原来的这一列删掉之后再填上去。
d = df["coloumn"].apply(lambda x: (x - MIN) / (MAX - MIN))
df = dff.drop("coloumn", axis=1)
df["coloumn"] = d
最后,老套路,宣传一波自己的公众号!(求关注哇!)
本人中大一肥宅,欢迎大家关注,请扫下面的二维码(〃’▽’〃)
如果觉得有帮助的话,可以扫码,赞赏鼓励一下!谢谢!