我正在尝试将列的内容从Dtype = object转换为Dtype = float64
我的代码:
df3["Undernourished"] = df3["Undernourished"].astype(str).astype(float)
代码返回以下警告:
<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)
转换似乎有效;但是对警告消息感到困惑。有人可以解释吗?