一招解决AttributeError: ‘DataFrame‘ object has no attribute ‘ix‘
一招解决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]。
还没有评论,来说两句吧...