【问题标题】:Pandas cannot read specific Excel sheetPandas 无法读取特定的 Excel 工作表
【发布时间】:2026-01-15 19:15:01
【问题描述】:

似乎这已经有了herehere 的答案,但是,这些解决方案都不适合我。

我正在努力

xls = pd.ExcelFile('input.xls')
df = pd.read_excel(xls, sheet_name="Sheet2") ## Also tried sheet_name = 1

无论如何,df 最终仍然包含第一张而不是第二张。我在 Python 3 和 Pandas 0.20.1(Anaconda 发行版)上。我错过了什么?如何将第二张工作表加载到df

【问题讨论】:

  • 尝试使用sheetname 而不是sheet_namesheet_name 在 Pandas 0.21.0 中替换了已弃用的 sheetname
  • 做到了!文档不正确吗?

标签: python excel pandas


【解决方案1】:

来自docs

sheetname :字符串,整数,字符串/整数的混合列表,或无,默认 0

自 0.21.0 版起已弃用:改用 sheet_name

这也意味着在0.21.0版本之前它曾经是sheetname ;-)

【讨论】: