如何解决将对象转换为float64时的警告消息
我正在尝试将列的内容从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)
转换似乎有效;但是对警告消息感到困惑。有人可以解释吗?
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。