AttributeError:"collections.OrderedDict"对象没有属性"iloc" [英] AttributeError: 'collections.OrderedDict' object has no attribute 'iloc'

查看:56
本文介绍了AttributeError:"collections.OrderedDict"对象没有属性"iloc"的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

import pandas as pd 

file = 'D:/myproject/chatbot_database.xlsx'
xl = pd.read_excel(file)
print(xl)                                        #this prints fine     
print(xl.iloc[0, 1])                             #this throws an error

错误消息是:

The error message is:

AttributeError:"collections.OrderedDict"对象没有属性'iloc'

AttributeError: 'collections.OrderedDict' object has no attribute 'iloc'

我尝试搜索stackoverflow并用谷歌搜索了2天,但是我似乎无法获得答案,所以我发布了这个问题.因此,主要问题是此代码在我的计算机上可用,但在我的朋友计算机上不起作用.我试图重新安装熊猫,希望这样可以解决iloc问题,因为iloc是熊猫的一部分,但无济于事.任何人都知道问题是什么吗?或可能缺少哪些其他库?

I have tried searching through stackoverflow and googled this for 2 days but i just don't seem to be able to get an answer so i am posting this question. So the main issue is that this code works on my computer but it does not work on my friends computer. I tried to reinstall pandas hoping that that would fix the iloc issue since iloc is part of pandas but no avail. Anyone has any idea what the issue is? or what other libraries may be missing?

下面的编辑帖子,下面的截图

推荐答案

  1. 首先请输入准确的错误消息.
  2. print(type(df)),它应该返回< class'pandas.core.frame.DataFrame'> 而不是'collections.OrderedDict'
  3. 在阅读时提及工作表名称 pd.read_excel(file.xlsx,sheet_name = sheet1) pd.read_excel(file.xlsx,sheet_name = None)(如果没有工作表名称)提供
  4. 在使用任何模块之前,请仔细阅读所有模块的文档
  1. first of all please put the exact error message.
  2. print(type(df)) it should return <class 'pandas.core.frame.DataFrame'> not 'collections.OrderedDict'
  3. while reading mention sheetname pd.read_excel(file.xlsx, sheet_name=sheet1) or pd.read_excel(file.xlsx, sheet_name=None) if no sheet name provided
  4. Please go through documentation of any modules before using it

这篇关于AttributeError:"collections.OrderedDict"对象没有属性"iloc"的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆