首页 > 其他 > 详细

pandas DataFrame 警告(SettingWithCopyWarning)

时间:2019-11-25 01:27:35      阅读:122      评论:0      收藏:0      [点我收藏+]

报警:

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

简单述之:

A为一个dataframe,

B = A[[‘a‘, ‘b‘]]
B[‘a‘] = B[‘a‘] + 1

将会有上面的警告,提示最后一行有问题,但实际上应该修改上一行,为:
B = A.loc[:,[‘a‘,‘b‘]]

详见:

https://www.cnblogs.com/pig-fly/p/7875472.html

pandas DataFrame 警告(SettingWithCopyWarning)

原文:https://www.cnblogs.com/sxinfo/p/11925357.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!