找回密码
 立即注册

扫一扫,访问微社区

QQ登录

只需一步,快速开始

查看: 2776|回复: 0

[求助] 使用pandas时SettingWithCopyWarning

1

主题

1

帖子

1

积分

贫民

积分
1
axllen 发表于 2021-2-1 11:01:17 | 显示全部楼层 |阅读模式
  1. C:\Users\xxx\AppData\Local\Programs\Python\Python37\python.exe D:/book/Python/workspace/autooss/lib/readExcelHelper.py
  2. C:\Users\xxx\AppData\Local\Programs\Python\Python37\lib\site-packages\pandas\core\indexing.py:362: SettingWithCopyWarning:
  3. A value is trying to be set on a copy of a slice from a DataFrame.
  4. Try using .loc[row_indexer,col_indexer] = value instead

  5. See the caveats in the documentation: http://pandas.pydata.org/pandas-docs/stable/indexing.html#indexing-view-versus-copy
  6.   self.obj[key] = _infer_fill_value(value)
  7. C:\Users\xxx\AppData\Local\Programs\Python\Python37\lib\site-packages\pandas\core\indexing.py:543: SettingWithCopyWarning:
  8. A value is trying to be set on a copy of a slice from a DataFrame.
  9. Try using .loc[row_indexer,col_indexer] = value instead

  10. See the caveats in the documentation: http://pandas.pydata.org/pandas-docs/stable/indexing.html#indexing-view-versus-copy
  11.   self.obj[item] = s
  12. D:/book/Python/workspace/autooss/lib/readExcelHelper.py:77: SettingWithCopyWarning:
  13. A value is trying to be set on a copy of a slice from a DataFrame

  14. See the caveats in the documentation: http://pandas.pydata.org/pandas-docs/stable/indexing.html#indexing-view-versus-copy
  15.   df2.drop_duplicates(['Location', 'Interface_prefix'], keep='first', inplace=True)
  16. C:\Users\xxx\AppData\Local\Programs\Python\Python37\lib\site-packages\pandas\core\frame.py:3940: SettingWithCopyWarning:
  17. A value is trying to be set on a copy of a slice from a DataFrame

  18. See the caveats in the documentation: http://pandas.pydata.org/pandas-docs/stable/indexing.html#indexing-view-versus-copy
  19.   errors=errors)

  20. Process finished with exit code 0
复制代码


为什么 df2.drop_duplicates(['Location', 'Interface_prefix'], keep='first', inplace=True) 会出现这个warning呢,求指教,谢谢
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

快速回复 返回顶部 返回列表