将对象转换为float64时的警告消息

时间:2020-11-06 10:07:31

标签: python pandas dataframe dtype

我正在尝试将列的内容从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)

转换似乎有效;但是对警告消息感到困惑。有人可以解释吗?

0 个答案:

没有答案
相关问题