python 加载excel报错
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了python 加载excel报错相关的知识,希望对你有一定的参考价值。
from pandas import Series, DataFrame
import pandas as pd
import numpy as np
import os
import sys
reload(sys)
sys.setdefultencoding(‘utf-8‘)
file1=pd.read_excel(‘F:/dataanalysis/statistics/PelicanStores.xlsx‘)
Python 加载excel报错:
IndexError: list index out of range
原因是PelicanStores.xlsx 的格式有问题,有未显示的多余列。
用excle打开文件PelicanStores.xlsx, 把内容复制到一个新的excel-PelicanStoresnew即可以。
file1=pd.read_excel(‘F:/dataanalysis/statistics/PelicanStoresnew.xlsx‘)
file1
Out[54]:
Customer Type of Customer Items Net Sales Method of Payment Gender 0 1 Regular 1 39.50 Discover Male
1 2 Promotional 1 102.40 Proprietary Card Female
2 3 Regular 1 22.50 Proprietary Card Female
3 4 Promotional 5 100.40 Proprietary Card Female
4 5 Regular 2 54.00 MasterCard Female
5 6 Regular 1 44.50 MasterCard Female
6 7 Promotional 2 78.00 Proprietary Card Female
[100 rows x 8 columns]
In [55]:
本文出自 “数据分析” 博客,请务必保留此出处http://emars.blog.51cto.com/1105517/1874749
以上是关于python 加载excel报错的主要内容,如果未能解决你的问题,请参考以下文章
python保存excel报错:PermissionError: [Errno 13] Permission denied: ‘xxx.xlsx‘
python保存excel报错:PermissionError: [Errno 13] Permission denied: ‘xxx.xlsx‘
python保存excel报错:PermissionError: [Errno 13] Permission denied: ‘xxx.xlsx‘
python excel操作 python操作excel方法
python3 使用 xlrd 库操作 excel.xlsx 时,报错: xlrd.biffh.XLRDError: Excel xlsx file; not supported