本文介绍: Mac pandas bug记录(路径及缓存问题)-Excel file format cannot be determined,you must specify an engine manually.
最近在做网上爬取财务数据的小项目,调试代码的过程中遇到了一个pandas 运行bug:pandas读取文件需要指定engine的类型。
1.问题:pandas 读写文件报错,
Excel file format cannot be determined,you must specify an engine manually.
见下图:
2.主要原因有两个:
2.1.打开excel会有”~$“开头的缓存文件。
2.2.Mac 下的pands运行有”.DS_Store“缓存文件。
如果存在缓存文件或者其他pandas默认读取不了的文件,就会让我们指定pandas的engine了。
3.解决办法:正确确定路径和清除缓存文件
通过if 判断是否有缓存文件,然后通过os.remove()移除,这样后续的pandas读取就不会报bug了。
声明:本站所有文章,如无特殊说明或标注,均为本站原创发布。任何个人或组织,在未征得本站同意时,禁止复制、盗用、采集、发布本站内容到任何网站、书籍等各类媒体平台。如若本站内容侵犯了原著者的合法权益,可联系我们进行处理。