pandas 写Excel 时报错:
Traceback (most recent call last):
File "D:\code_tool\spiderYesmro3\main.py", line 244, in <module>
main()
File "D:\code_tool\spiderYesmro3\main.py", line 33, in main
df.to_excel(writer, sheet_name=cate, header=excel_title, index=False)
File "D:\code_tool\spiderYesmro3\venv\lib\site-packages\pandas\util\_decorators.py", line 211, in wrapper
return func(*args, **kwargs)
File "D:\code_tool\spiderYesmro3\venv\lib\site-packages\pandas\util\_decorators.py", line 211, in wrapper
return func(*args, **kwargs)
File "D:\code_tool\spiderYesmro3\venv\lib\site-packages\pandas\core\generic.py", line 2374, in to_excel
formatter.write(
File "D:\code_tool\spiderYesmro3\venv\lib\site-packages\pandas\io\formats\excel.py", line 950, in write
writer._write_cells(
File "D:\code_tool\spiderYesmro3\venv\lib\site-packages\pandas\io\excel\_openpyxl.py", line 492, in _write_cells
for cell in cells:
File "D:\code_tool\spiderYesmro3\venv\lib\site-packages\pandas\io\formats\excel.py", line 887, in get_formatted_cells
for cell in itertools.chain(self._format_header(), self._format_body()):
File "D:\code_tool\spiderYesmro3\venv\lib\site-packages\pandas\io\formats\excel.py", line 691, in _format_header_regular
raise ValueError(
ValueError: Writing 0 cols but got 8 aliases
复现:
参考资料:
标签:line,code,tool,py,Excel,cols,spiderYesmro3,pandas From: https://www.cnblogs.com/czzz/p/17081370.htmlhttps://blog.csdn.net/weixin_45249324/article/details/125970832