使用Pandas对同一工作簿的多个工作表进行pd.read_excel() [英] Using Pandas to pd.read_excel() for multiple worksheets of the same workbook

查看:4921
本文介绍了使用Pandas对同一工作簿的多个工作表进行pd.read_excel()的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个大型的电子表格文件(.xlsx),我正在使用python大熊猫进行处理。这发生在我需要这个大文件中的两个选项卡的数据。其中一个标签有大量数据,另外一个数据只有几个方形单元格。



当我使用 pd.read_excel()在任何工作表中,它看起来像整个文件是加载(不只是我感兴趣的工作表)。所以当我使用这个方法两次(每张表单一次)时,我有效地要忍受整个工作簿读取两次(尽管我们只使用指定的表)。



/ p>

解决方案

尝试

  xls = pd.ExcelFile('path_to_file.xls')
df1 = xls.parse('Sheet1')
df2 = xls.parse('Sheet2')

没有仔细看到看到在第一行完成了多少,后续行中已经完成了多少,但至少是一个开始玩耍的地方。


I have a large spreadsheet file (.xlsx) that I'm processing using python pandas. It happens that I need data from two tabs in that large file. One of the tabs has a ton of data and the other is just a few square cells.

When I use pd.read_excel() on any worksheet, it looks to me like the whole file is loaded (not just the worksheet I'm interested in). So when I use the method twice (once for each sheet), I effectively have to suffer the whole workbook being read in twice (even though we're only using the specified sheet).

Am I using it wrong or is it just limited in this way?

Thank you!

解决方案

Try this:

xls = pd.ExcelFile('path_to_file.xls')
df1 = xls.parse('Sheet1')
df2 = xls.parse('Sheet2')

Haven't looked closely to see how much is done in the first line and how much is done in subsequent lines, but it's at least a place to start playing around.

这篇关于使用Pandas对同一工作簿的多个工作表进行pd.read_excel()的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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