pandas.read_excel参数"sheet_name";不工作 [英] pandas.read_excel parameter "sheet_name" not working

查看:737
本文介绍了pandas.read_excel参数"sheet_name";不工作的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

根据文档pandas.read_excel具有参数sheet_name,该参数允许指定读取哪张纸.但是,当我尝试从excel文件读取第二张表时,无论我如何设置参数(sheet_name = 1sheet_name = 'Sheet2'),数据框始终显示第一张表,并传递索引列表(sheet_name = [0, 1] )不返回数据帧的字典,但仍返回第一张表.这里可能是什么问题?

According to the doc, pandas.read_excel has a parameter sheet_name that allows specifying which sheet is read. But when I am trying to read the second sheet from an excel file, no matter how I set the parameter (sheet_name = 1, sheet_name = 'Sheet2'), the dataframe always shows the first sheet, and passing a list of indices (sheet_name = [0, 1]) does not return a dictionary of dataframes but still the first sheet. What might be the problem here?

推荐答案

您似乎正在使用旧版本的Python. 因此,尝试更改您的代码

It looks like you're using the old version of Python. So try to change your code

df = pd.read_excel(file_with_data, sheetname=sheet_with_data)

它应该正常工作.

这篇关于pandas.read_excel参数"sheet_name";不工作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆