我是靠谱客的博主 苗条猎豹,这篇文章主要介绍Pandas读取Excel文件报错IndexError: list index out of range,现在分享给大家,希望可以做个参考。

import pandas as pd
data = pd.read_excel(path,sheet_name=1)

直接读取文件报错IndexError: list index out of range通过上网查说是Excel中有很多多余的没有数据的行和列,但是手动删除也没有用,可以通过以下方法读取:

import os
import pandas as pd
path = r'文件所在路径'
excelFile = os.path.join(path,'文件名.xls')

data = pd.read_excel(excelFile)

就没问题啦!
 

最后

以上就是苗条猎豹最近收集整理的关于Pandas读取Excel文件报错IndexError: list index out of range的全部内容,更多相关Pandas读取Excel文件报错IndexError:内容请搜索靠谱客的其他文章。

本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
点赞(120)

评论列表共有 0 条评论

立即
投稿
返回
顶部