read_csv报错:OSError: Initializing from file failed

read_csv报错:OSError: Initializing from file failed 

python version 3.6

import pandas as pd
df = pd.read_csv(r'C:\Users\ZHAOLAN\Desktop\Python数据集\train-pivot.csv',sep= ",")
print(df)

Error message: OSError: Initializing from file failed

Error reason:
When calling the read_csv() method of pandas, C language is used as the parsing language by default. When the file name contains Chinese, C engine is used in some cases. An error will occur next time. Therefore, you can eliminate this error by specifying engine as Python when calling the read_csv() method.
The writing method is as follows:
df = pd.read_csv(r'C:\Users\ZHAOLAN\Desktop\Python Dataset\train-pivot.csv 39;,sep= ",",engine = 'python')
print(df)

おすすめ

転載: blog.csdn.net/qq_72290695/article/details/134609760