【发布时间】:2015-02-23 21:34:26
【问题描述】:
使用SettingWithCopyWarning,有时它会将您指向模块中触发警告的确切代码行(例如here),有时则不会(例如here)。
没有遍历代码的每一行(如果您正在查看数百行代码,这听起来不太吸引人),有没有一种方法可以确定触发警告的代码行,假设警告没有返回那个信息?
我想知道这是否是警告中的一个错误,即返回警告而不查明触发它的特定代码。
Warning (from warnings module):
File "C:\Python34\lib\site-packages\pandas\core\indexing.py", line 415
self.obj[item] = s
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 the caveats in the documentation: http://pandas.pydata.org/pandas-docs/stable/indexing.html#indexing-view-versus-copy
Python 3.4、Pandas 0.15.0
【问题讨论】: