pandas dataframe返回NaN

2024-10-02 10:24:24 发布

您现在位置:Python中文网/ 问答频道 /正文

我正在用pandas阅读我的excel表格,逐行迭代并用它做一些事情。我的输入文件只有7行,其中有一些rocord。但是,当我打印数据帧时,我得到了如下所示的结果,其中有额外的行带有“NaN”。当我的脚本迭代索引7时,它会失败,并出现ValueError异常。在

inputfile = r'C:\Users\users\Desktop\release\someexcel.xlsx'
dfr = pan.read_excel(inputfile, skiprows=3, sheetname=1)
print (dfr)

以下例外与此问题无关。但当脚本试图执行索引7中的脚本时,出现了以下情况:

^{pr2}$

这是我的输入文件:

enter image description here

数据帧如下所示:

enter image description here

你知道为什么会这样吗?我该怎么解决这个问题?在


Tags: 文件数据脚本pandasnan事情excelusers

热门问题