乔山办公网我们一直在努力
您的位置:乔山办公网 > excel表格制作 > <em>pandas</em> <em>read</em>_<em

<em>pandas</em> <em>read</em>_<em

作者:乔山办公网日期:

返回目录:excel表格制作


注意最后一行的错误提示:

FileNotFoundError: [Errno 2] No such file or directory: 'J:/Pepole.xlsx'

这表示此文件在你电脑中不存在,请检查该路径的合法性!



你这个报错不是贴的这几行,能贴全点么
我这用跟你一样的代码能测试通过。
你help(pd.read_excel),看看都有哪些参数
利用Python的pandas数据结构来读取excel表格的数据,部分代码如下:

#-*- coding:utf-8 -*-
import pandas as pd
import matplotlib.pyplot as plt

catering_data="catering_sale.xls"
data=pd.read_excel(catering_data,index_col=u'日期')
#读取数据,指定"日期"列为索引列

大多数书上都是这样写的,但是在Python2.7上运行时出现错误。(没有e79fa5e98193e4b893e5b19e337在Python3.x版本试过)
出现了如下问题:
这里写图片描述
使用help(pd.read_excel)发现参数中有必选参数sheetname,加入到函数中,代码如下:

#-*- coding:utf-8 -*-
import pandas as pd
import matplotlib.pyplot as plt

catering_data="catering_sale.xls"
data=pd.read_excel(catering_data,sheetname=0,index_col=u'日期')

运行成功。
sheetname=0 的意思是:读取xls文件中的第一个表格。(假设文件中有很多个表格)
另外,也可以将文件转换成csv格式,就不需要这个参数了。代码如下:

catering_data="catering_sale.csv"
data=pd.read_csv(catering_data)

import pandas as pd
df = pd.read_excel(open('路径','rb'), sheetname='Sheet 1')

sheetname这里是字符串啊

相关阅读

  • <em>pandas</em> <em>read</em>_<em

  • 乔山办公网excel表格制作
  • 注意最后百一行的错误提度示:FileNotFoundError: [Errno 2] No such file or directory: J:/Pepole.xlsx这表示此知文件在你电脑中不存在道,请检查专该路径的合法属性!pandas模块读取excel时的问题求.
关键词不能为空
极力推荐

ppt怎么做_excel表格制作_office365_word文档_365办公网