You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

pandas.read_excel()读取文件随机跳行且单元格设为NaN的问题

Pandas读取Excel文件异常问题

使用pandas读取目标Excel文件时遇到两个异常:

  • 原文件共44行,但读取后仅得到15行,无明显规律
  • 单元格E31被错误识别为nan

查阅pandas官方文档后未找到可解决该问题的相关参数。

复现步骤

环境信息

% pip show pandas
Name: pandas
Version: 1.5.1
(...)
% python3
Python 3.10.7 (main, Sep 15 2022, 01:51:29) [Clang 14.0.0 (clang-1400.0.29.102)] on darwin

执行代码与结果

>>> import pandas
>>> test = pandas.read_excel("Downloads/invalid_file.xlsx")
>>> test
              name                    super       object  ... comment_rm gui_element  gui_attributes
0     hasSignature                 hasValue    TextValue  ...        NaN  SimpleText             NaN
1       hasCreator                 hasValue    TextValue  ...        NaN  SimpleText             NaN
2   hasProvenience                 hasValue    TextValue  ...        NaN  SimpleText             NaN
3          hasDate                 hasValue    TextValue  ...        NaN  SimpleText             NaN
4      hasLanguage                 hasValue    TextValue  ...        NaN  SimpleText             NaN
5     hasCopyright                 hasValue    TextValue  ...        NaN  SimpleText             NaN
6       hasComment                 hasValue    TextValue  ...        NaN    Textarea             NaN
7   hasDescription                 hasValue    TextValue  ...        NaN    Richtext             NaN
8     hasLatinName  hasValue, dcterms:title    TextValue  ...        NaN  SimpleText             NaN
9       hasSynonym                 hasValue     Synonyme  ...        NaN  SimpleText             NaN
10      hasPagenum                   seqnum     IntValue  ...        NaN  SimpleText             NaN
11          partOf                 isPartOf  :Manuscript  ...        NaN   Searchbox             NaN
12        hasTitle                 hasValue    TextValue  ...        NaN  SimpleText             NaN
13        hasFolio                 hasValue    TextValue  ...        NaN  SimpleText             NaN
14        hasPlant                hasLinkTo       :Plant  ...        NaN   Searchbox             NaN

[15 rows x 15 columns]
>>> test.iloc[9,4]
nan

内容的提问来源于stack exchange,提问作者Johannes Nussbaum

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.08.14 14:40:34