赞
踩
调用pandas的read_csv()方法时,默认使用C engine作为parser engine,而当文件名中含有中文的时候,用C engine在部分情况下就会出错。所以在调用read_csv()方法时指定engine为Python就可以解决问题了。
file = pd.read_csv(filename, engine='python')
同时也可以通过先打开文件在读取的方法是实现Pandas读取文件名包含中文的文件:
import pandas as pd
f=open('C:\\Users\\Desktop\\测试.csv')
df=pd.read_csv(f)
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。