I'm trying to duplicate a column in my DataFrame and could not get rid off the warning SettingWithCopyWarning :
I've tried :
df['new_col'] = df['old_col']
df.loc[:, 'new_col'] = df['old_col']
df.loc[:, 'new_col'] = df['old_col'].copy()
df.loc[:, 'new_col'] = df.loc[:,'old_col']
The result is always a Warning like this one
Warning (from warnings module):
File "C:\Users\frank\Documents\orange\Python\Jira\jira_initiatives_dashboard.py", line 267
df.loc[:, 'new_col'] = df['old_col']
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: https://pandas.pydata.org/pandas-docs/stable/user_guide/indexing.html#returning-a-view-versus-a-copy
Documentation does not seem to explain when there are multiple values instead of one value. What's wrong?