pandas :在Excel文件中查找工作表列表 [英] Pandas: Looking up the list of sheets in an excel file

查看:110
本文介绍了 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是先验的.

but I don't know N a priori.

有什么方法可以从Pandas的excel文档中获取工作表列表吗?

Is there any way to get the list of sheets from an excel document in Pandas?

推荐答案

您仍然可以使用

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屋!

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