'DataFrame' object has no attribute 'ix'
时间: 2023-09-08 14:08:11 浏览: 188
"'DataFrame' object has no attribute 'ix'" 是因为在最新版本的pandas中,ix属性已被废弃,不再推荐使用。 在使用DataFrame.ix时会出现这个错误。要解决这个问题,可以考虑使用其他代替ix的方法,比如使用iloc或loc来进行数据块选择。 例如,可以将代码中的fdata.ix替换为fdata.loc或fdata.iloc来解决此问题。具体代码如下:
fdata.loc[fdata['time']=='Diner', 'time'] = 'Dinner'
fdata.loc[fdata['time']=='Dier', 'time'] = 'Dinner'
fdata['time'].unique()
使用loc或iloc方法,可以实现相同的功能,并且不会出现"'DataFrame' object has no attribute 'ix'"错误。<span class="em">1</span><span class="em">2</span><span class="em">3</span>
#### 引用[.reference_title]
- *1* *2* [已解决:pandas报AttributeError: DataFrame object has no attribute ix错误](https://blog.csdn.net/mahoon411/article/details/118917335)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v93^chatsearchT3_2"}}] [.reference_item style="max-width: 50%"]
- *3* [编写Python 代码出现 AttributeError: ‘DataFrame‘ object has no attribute ‘ix‘ 报错](https://blog.csdn.net/qq_62127918/article/details/130806580)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v93^chatsearchT3_2"}}] [.reference_item style="max-width: 50%"]
[ .reference_list ]
阅读全文