报警:

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

相关文章:

  • 2022-12-23
  • 2021-09-13
  • 2021-04-16
  • 2022-01-22
  • 2021-04-08
  • 2021-11-27
  • 2022-01-20
  • 2021-08-12
猜你喜欢
  • 2022-12-23
  • 2021-06-24
  • 2022-01-25
  • 2021-10-29
  • 2021-06-14
相关资源
相似解决方案