使用熊猫:功能匹配列名,无法执行功能

发布于 2025-01-30 02:25:50 字数 216 浏览 3 评论 0原文

一个名为“ 等级”的列的客户端给我一个表df.rank.astype(int)函数在列上认为我正在尝试在.rank()函数上运行.astype()函数。有什么方法可以防止这种情况?

df.rank.astype()
AttributeError: 'function' object has no attribute 'astype'

I was given a table by a client named with a column named "rank",
and I'm trying to convert the values in that column to an int type, but when I try to run the df.rank.astype(int) function on the column it thinks I'm trying to run the .astype() function on the .rank() function. Any way to prevent this?

df.rank.astype()
AttributeError: 'function' object has no attribute 'astype'

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

怎言笑 2025-02-06 02:25:50

您可以使用[]设置声明列

df['rank'] = df['rank'].astpye()

You can set declare the column using []

df['rank'] = df['rank'].astpye()
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文