Pandas:在 excel 文件中查找工作表列表 [英] Pandas: Looking up the list of sheets in an excel file
本文介绍了Pandas:在 excel 文件中查找工作表列表的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
新版Pandas使用如下界面加载Excel文件:
The new version of Pandas uses the following interface to load Excel files:
read_excel('path_to_file.xls', 'Sheet1', index_col=None, na_values=['NA'])
但是如果我不知道可用的床单怎么办?
but what if I don't know the sheets that are available?
例如,我正在处理以下工作表的 excel 文件
For example, I am working with excel files that the following sheets
数据 1、数据 2 ...、数据 N、foo、bar
Data 1, Data 2 ..., Data N, foo, bar
但我不知道 N
先验.
有没有办法从 Pandas 中的 Excel 文档中获取工作表列表?
Is there any way to get the list of sheets from an excel document in Pandas?
推荐答案
您仍然可以使用 ExcelFile 类(和 sheet_names
属性):
You can still use the ExcelFile class (and the sheet_names
attribute):
xl = pd.ExcelFile('foo.xls')
xl.sheet_names # see all sheet names
xl.parse(sheet_name) # read a specific sheet to DataFrame
查看解析文档了解更多选项...
see docs for parse for more options...
这篇关于Pandas:在 excel 文件中查找工作表列表的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文