Pandas read_excel在读取excel文件时给出yes no



使用panda读取excel。我知道它很简单,但数据帧输出只是"是"one_answers"否"。

关于excel文件,只有11列具有正常数据,单个表格,表格名称为Sheet1

In [1]: import pandas
In [2]: import pandas as pd
In [3]: data = pd.read_excel('/path/fileName.xlsx')
In [4]: data
Out[4]:
No
0  Yes

使用Python 3.6.10(默认值,2020年5月24日,21:54:41(和IPython 6.5.0。

我已经尝试过的东西:

  1. 将给定excel中的数据复制到一个新的excel文件中,并尝试使用read_excel进行读取,结果如预期
  2. 浏览文档
  3. 在网上搜索一些解决方案

非常感谢您的帮助。

当我开始将excel文件导入Ipython时,我遇到了类似的问题,但过了一段时间我还是解决了。

尝试以下操作:

在[1]:import pandas

在[2]中:import pandas as pd

在[3]中:df = pd.read_excel(r'/path/fileName.xlsx', sheet_name =0)

df.head()

确保你添加字母r,就像我上面在你电脑上的数据路径之前所做的那样。

第二种方法:

import openpyxl as op
from openpyxl import load_workbook
df = load_workbook(r"path of your dataset in your PC", sheet_name = 0)
df.head()

以上内容将显示您在第一个工作表中的内容。重复相同的代码并更改sheet_name=1、2、3、,。。。。。。查看其他人。

相关内容

最新更新