一招解决AttributeError: ‘DataFrame‘ object has no attribute ‘ix‘

末蓝、 2024-02-22 07:31 168阅读 0赞

一招解决AttributeError: ‘DataFrame‘ object has no attribute ‘ix‘

文章目录

    • 问题描述
    • 解决思路
    • 解决方法

问题描述

AttributeError: ‘DataFrame‘ object has no attribute ‘ix‘

解决思路

在 Pandas 中,ix 已经被弃用,可以使用 loc 或 iloc 来代替。

解决方法

下滑查看解决方法

如果出现 ‘DataFrame’ object has no attribute ‘ix’ 的错误

,可以将代码中的 ix 替换为 loc 或 iloc。

例如,

将 df.ix[0, ‘column_name’]

替换为

df.loc[0, ‘column_name’] 或 df.iloc[0, column_index]。

发表评论

表情:
评论列表 (有 0 条评论,168人围观)

还没有评论,来说两句吧...

相关阅读