Excel file format cannot be determined, you must specify an engine manually

大家在利用pandas读取excel文件的时候,一定会碰到类似的问题;这里主要写一下我踩过的坑:
#官网pandas对engine的解释
enginestr, default None
If io is not a buffer or path, this must be set to identify io. Supported engines: “xlrd”, “openpyxl”, “odf”, “pyxlsb”. Engine compatibility :

“xlrd” supports old-style Excel files (.xls).

“openpyxl” supports newer Excel file formats.

“odf” supports OpenDocument file formats (.odf, .ods, .odt).

“pyxlsb” supports Binary Excel files.

Changed in version 1.2.0: The engine xlrd now only supports old-style .xls files. When engine=None, the following logic will be used to determine the engine:

If path_or_buffer is an OpenDocument format (.odf, .ods, .odt), then odf will be used.

Otherwise if path_or_buffer is an xls format, xlrd will be used.

Otherwise if path_or_buffer is in xlsb format, pyxlsb will be used.

New in version 1.3.0.

Otherwise openpyxl will be used.

但是,我们大部分应该是下载Exel文件的时候,里面内容的格式很乱导致pandas不知道用那个engine工作,所以才会让你手动ing指定engine。这里很简单你把文件另存为相应的格式就欧克了。

你可能感兴趣的:(pandas,Tushare,网络,python,算法)