有时候,SettingWithCopyWarning
会指向触发警告的模块中的确切代码行(例如这里),而其他时候则不会(例如这里)。
除了逐行查看代码(如果您要审核数百行代码,听起来并不太吸引人),是否有一种方法可以定位触发警告的代码行,假设警告没有返回该信息?
我想知道这是否是警告中存在错误,没有确定触发它的特定代码。
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