Having read this answer, I tried to do the following to avoid SettingWithCopyWarning
.
So I did below. Yet it still generates the warning below. What have I done wrong ?
df_filtered.loc[:,'MY_DT'] = pd.to_datetime(df_filtered['MY_DT'])
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
My column was originally a string
df_filtered['MY_DT']
Out[3]:
0 4/24/2020
1 4/24/2020
2 4/24/2020
3 4/24/2020
10 4/24/2020
...
1937 4/30/2020
1938 4/30/2020
1939 4/30/2020
1940 4/30/2020
1941 4/30/2020
Name: MY_DT, Length: 1896, dtype: object