Python错误:索引器错误:无法从空轴执行非空获取

Python错误:索引器错误:无法从空轴执行非空获取,python,excel,python-2.7,pandas,Python,Excel,Python 2.7,Pandas,我从命令提示符处收到以下错误: Traceback (most recent call last): File "C:\Python27\Scripts\read_csv.py", line 14, in <module> df3.to_excel(writer, sheet_name="Section 3") File "C:\Python27\lib\site-packages\pandas\core\frame.py", line 1464, in to_ex cel star

我从命令提示符处收到以下错误:

Traceback (most recent call last):
File "C:\Python27\Scripts\read_csv.py", line 14, in <module>
df3.to_excel(writer, sheet_name="Section 3")
File "C:\Python27\lib\site-packages\pandas\core\frame.py", line 1464, in to_ex
cel
startrow=startrow, startcol=startcol)
 File "C:\Python27\lib\site-packages\pandas\io\excel.py", line 1517, in  write_cells
for cell in cells:
  File "C:\Python27\lib\site-packages\pandas\formats\format.py", line 1893, in get_formatted_cells
self._format_body()):
  File "C:\Python27\lib\site-packages\pandas\formats\format.py", line 1864, in _format_hierarchical_rows
fill_value=True)
  File "C:\Python27\lib\site-packages\pandas\indexes\base.py", line 1515, in take
na_value=self._na_value)
  File "C:\Python27\lib\site-packages\pandas\indexes\base.py", line 1534, in _assert_take_fillable
taken = values.take(indices)
IndexError: cannot do a non-empty take from an empty axes.
Exception Exception: Exception('Exception caught in workbook destructor. Explicit close() may be required for workbook.',) in <bound method Workbook.__del__ of
<xlsxwriter.workbook.Workbook object at 0x024BF5B0>> ignored

在黑暗中拍摄:保存后您是否尝试过
writer.close()
?这是我的第一个想法。应该包含该代码,但它仍然会显示相同的错误。我将编辑我的帖子以包含它。请发布完整的stacktrace。添加了整个错误真正的错误是
索引器:无法从空轴执行非空拍摄。
黑暗中拍摄:您尝试过
writer.close()吗
保存之后?这是我的第一个想法。本应包含该代码,但仍会显示相同的错误。我将编辑帖子以包含该错误。请发布完整的stacktrace。添加了整个错误真正的错误是
索引器错误:无法从空轴执行非空提取。
import pandas as pd

df1=pd.read_csv("File1.csv")
df2=pd.read_csv("File2.csv")
df3=pd.read_csv("File3.csv")

# Creates a Pandas Excel writer using XlsxWriter as the engine
writer = pd.ExcelWriter("Excel File", engine="xlsxwriter")

# Convert data frames to an XlsxWriter Excel Object
df1.to_excel(writer, sheet_name="Section 1")
df2.to_excel(writer, sheet_name="Section 2")
df3.to_excel(writer, sheet_name="Section 3")

# Close the Pandas Excel writer and output the Excel file.
writer.save()
writer.close()