This question is somewhat similar to: Remap values in pandas column with a dict, however, the answers are quite dated and do not cover the "SettingWithCopyWarning".
I am simply trying to replace the original strings in a column, "col", of my dataframe, "df", using a dictionary, "dict1". Here is my code which successfully replaces the values:
temp_series = df.loc[:,col].copy()
for name in temp_series:
for old, new in q_names_dict.items():
if (old.lower() == name.lower()):
temp_series.replace(name, new, inplace=True)
-However, when I attempt to update my original dataframe with this copy, "temp_series", I get a "SettingWithCopyWarning". Here is the code which throws that warning:
df.loc[:,col] = temp_series
# The bottom three don't work either.
#df[col] = temp_series
#df.loc[:,col].update(temp_series)
#df[col].update(temp_series)