python写入到excel时报错,代码是按视频写的(视频链接:https://www.bilibili.com/video/BV1HY4y1874L/?spm_id_from=333.788),一运行就报错
代码:
print(df)
df.to_excel('d:/大数据分析/利润表.xlsx/')
报错:
Traceback (most recent call last):
File "D:\Users\Xuan\PycharmProjects\pythonProject\venv\Lib\site-packages\pandas\io\excel\_base.py", line 1144, in __new__
engine = config.get_option(f"io.excel.{ext}.writer", silent=True)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "D:\Users\Xuan\PycharmProjects\pythonProject\venv\Lib\site-packages\pandas\_config\config.py", line 263, in __call__
return self.__func__(*args, **kwds)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "D:\Users\Xuan\PycharmProjects\pythonProject\venv\Lib\site-packages\pandas\_config\config.py", line 135, in _get_option
key = _get_single_key(pat, silent)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "D:\Users\Xuan\PycharmProjects\pythonProject\venv\Lib\site-packages\pandas\_config\config.py", line 121, in _get_single_key
raise OptionError(f"No such keys(s): {repr(pat)}")
pandas._config.config.OptionError: No such keys(s): 'io.excel..writer'
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "D:\Users\Xuan\PycharmProjects\pythonProject\task.py", line 92, in <module>
df.to_excel('d:/大数据分析/利润表.xlsx/')
File "D:\Users\Xuan\PycharmProjects\pythonProject\venv\Lib\site-packages\pandas\util\_decorators.py", line 211, in wrapper
return func(*args, **kwargs)
^^^^^^^^^^^^^^^^^^^^^
File "D:\Users\Xuan\PycharmProjects\pythonProject\venv\Lib\site-packages\pandas\util\_decorators.py", line 211, in wrapper
return func(*args, **kwargs)
^^^^^^^^^^^^^^^^^^^^^
File "D:\Users\Xuan\PycharmProjects\pythonProject\venv\Lib\site-packages\pandas\core\generic.py", line 2374, in to_excel
formatter.write(
File "D:\Users\Xuan\PycharmProjects\pythonProject\venv\Lib\site-packages\pandas\io\formats\excel.py", line 918, in write
writer = ExcelWriter( # type: ignore[abstract]
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "D:\Users\Xuan\PycharmProjects\pythonProject\venv\Lib\site-packages\pandas\io\excel\_base.py", line 1148, in __new__
raise ValueError(f"No engine for filetype: '{ext}'") from err
ValueError: No engine for filetype: ''