熊猫ExcelFile sheet_names返回空列表

时间:2020-03-30 18:19:42

标签: python pandas

如主题所示,我正在从github上的原始xlsx文件创建ExcelFile对象,当我调用C:\MinGW\bin 属性时,将返回一个空列表。工作表名称有两个,“ Trips”和“ Description”。

.sheet_names

很抱歉,如果这是重复的,我搜索了类似的东西,但找不到任何东西。任何帮助将不胜感激,谢谢!

1 个答案:

答案 0 :(得分:2)

这里的问题是您的源文件有缺陷,

如果您使用openpyxl

import openpyxl 

openpyxl.load(("https://github.com/j-on-son/Data/blob/master/ISyE3803/Relay%20Bikes/Relay%20Bikes/Relay%20Trips.xlsx?raw=true")

您将正确地得到一个错误:

  UserWarning: File contains an invalid specification for Trips. This will be removed
  warn(msg)
  UserWarning: File contains an invalid specification for Decriptions. This will be removed
  warn(msg)

使用Microsoft Office的Open XML生产力工具测试其有效性

最好的选择是使用Excel打开它,然后将其重新保存为xlsx,应该可以解决此问题。