【问题标题】:chunksize keyword of read_excel is not implemented未实现 read_excel 的 chunksize 关键字
【发布时间】:2017-07-27 17:14:30
【问题描述】:

在 0.16.1 版本中,chunksize 参数可用。

见:http://pandas.pydata.org/pandas-docs/version/0.16.1/generated/pandas.ExcelFile.parse.html

但在最新版本中它不可用。

https://pandas.pydata.org/pandas-docs/stable/generated/pandas.ExcelFile.parse.html

删除的原因是什么?

另外,最新版本的excel文件如何分块处理?

我以前在下面做:

import pandas as pd

excel = pd.ExcelFile("test.xlsx")

for sheet in excel.sheet_names:
    reader = excel.parse(sheet, chunksize=1000)
    for chunk in reader:
        # process chunk

【问题讨论】:

标签: python pandas


【解决方案1】:

正如EdChum 在评论中解释的那样,此功能在 0.17.0 中已删除。 Chris 在评论中给出了相同的理由:

没有特别令人信服的理由;主要的想法是匹配 to_excel的api,即“ExcelFileWrapper”(ExcelFile,ExcelWriter) 没有任何特定于 pandas 的功能,而是通过它 进入 io 函数(read_excel、to_excel)。

我确实更新了文档以涵盖该特定示例。编辑:虽然 在 diff 中可能很难看到 - 如下所示。

来源:https://github.com/pandas-dev/pandas/pull/11198

我仍然想知道是否有其他方法可以分块阅读 excel?

【讨论】:

  • 有谁知道是否有快速的方法来做到这一点?
猜你喜欢
  • 2017-11-29
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2011-03-05
  • 2010-11-14
相关资源
最近更新 更多