This code produces the SettingWithCopyWarning as follows:
raw_corpus.loc[:,'constructed_recipe']=raw_corpus.loc[:,'trigger_channel_cat'] + " " + raw_corpus.loc[:,'trigger_channel_clean'] + " " + raw_corpus.loc[:,'trigger_name_clean'] + " " + raw_corpus.loc[:,'action_name_clean'] +" " + raw_corpus.loc[:,'action_channel_clean'] +" " + raw_corpus.loc[:,'action_channel_cat']
/Users/dlhoffman/anaconda3/envs/gensim-py35/lib/python3.5/site-packages/pandas/core/indexing.py:537: 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
self.obj[item] = s
This code produces a different warning:
raw_corpus['constructed_recipe']=raw_corpus['trigger_channel_cat'] + " " + raw_corpus['trigger_channel_clean'] + " " + raw_corpus['trigger_name_clean'] + " " + raw_corpus['action_name_clean'] +" " + raw_corpus['action_channel_clean'] +" " + raw_corpus['action_channel_cat']
/Users/dlhoffman/anaconda3/envs/gensim-py35/lib/python3.5/site-packages/ipykernel_launcher.py:5: 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
"""
Both pieces of code do what I want, but the error is annoying and it's my understanding that this is not a good error. I've read up on the documentation and also people's suggestions here, but can't figure out what I am doing wrong.