I am trying to replace the column 'let'
in the DataFrame london
(which is a copy of another no_eco
) with rows that only contain the strings in the contains()
method. The code is as follows:
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)
The code works and I have dropped the rows where the strings are not met however I receive the following warning:
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
and when looking at the documentation, I still can't understand what I am doing wrong.
Is this okay to continue using variable london
or will I encounter problems in the future?
Thanks.