在大约 100 个 excel 文件上使用 pandas read_excel - 有些文件很大 - 我想读取每个文件的前几行(标题和前几行数据)。
这不起作用,但说明了目标(例如读取 10 个数据行):
workbook_dataframe = pd.read_excel(workbook_filename, nrows = 10)
Run Code Online (Sandbox Code Playgroud)
这是我目前的解决方法:
workbook_dataframe = pd.read_excel(workbook_filename).head(10)
Run Code Online (Sandbox Code Playgroud)
解决方法的问题是它必须在取头之前读取整个 excel 文件。我也尝试过使用skiprows 和skip_footer 进行试验,给它提供只会产生错误的负数。
目前尚不支持此功能,但从代码来看,它看起来并不难。您可以在 Github 项目页面上提出问题:https://github.com/pandas-dev/pandas/issues。
| 归档时间: |
|
| 查看次数: |
3698 次 |
| 最近记录: |