这两天在给DataFrame元素赋值运行时出现错误,于是按照所给的错误提示就在网上搜索了一下:
frame['price'][2]=10 <ipython-input-30-d74688b360d7>:1: SettingWithCopyWarning: A value is trying to be set on a copy of a slice from a DataFrame See the caveats in the documentation: https://pandas.pydata.org/pandas-docs/stable/user_guide/indexing.html#returning-a-view-versus-a-copy frame['price'][2]=10
后来得到的解决方法:
dfd = frame.copy() dfd.loc[2,'price']=10
成功解决!
下面详述解决的过程:
根据提示在网上搜索 进入相关错误提示页面