I am trying to convert the content of a column from Dtype=object to Dtype=float64
My code:
df3["Undernourished"] = df3["Undernourished"].astype(str).astype(float)
The code returns the following warning:
<ipython-input-24-f03715ac98fd>:1: 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
df3["Undernourished"] = df3["Undernourished"].astype(str).astype(float)
The conversion seems to have worked; but am confused about the warning message. Can someone please explain?