python加载excel报错解决方法

这篇文章主要为大家详细介绍了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]:

以上就是python加载excel报错解决方法的详细内容,更多请关注 第一php社区 其它相关文章!

Posted in 未分类

发表评论