我正在尝试用仅包含方法中字符串的行替换'let'
DataFrame 中的列london
(它是 another 的副本) 。代码如下:no_eco
contains()
london = no_eco
london.loc[:,'let'] = london.loc[:,'let'].str.contains('E' or 'D' or 'F' or 'G' or 'H' or 'I' or 'J')
london.loc[:,'let'] = london.loc[:,'let'][london.loc[:,'let']]
london = london.dropna(subset = ['let'])
print(london)
代码有效,我已经删除了不满足字符串的行,但是我收到以下警告:
C:\Users\gerardchurch\AppData\Local\Continuum\anaconda3\lib\site-packages\pandas\core\indexing.py:543: 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
在查看文档时,我仍然无法理解我做错了什么。
可以继续使用变量london
还是我将来会遇到问题?
谢谢。