示例:

path = r'E:\pyspace\数据集'
data_file = os.path.join(path, "income_dist.csv")
pd.read_csv(data_file)

pandas 读取文件时报错 Initializing from file failed

 

。。。。。。

 pandas 读取文件时报错 Initializing from file failed

 

原因:

文件名称中包含中文字符。

 

解决办法有二:

1、更改文件名称,替换其中的中文字符。

 

2、用 open() 函数作为中间参数进行传递

path = r'E:\pyspace\数据集'
data_file = os.path.join(path, 'income_dist.csv')
pd.read_csv(open(data_file))

 

相关文章:

  • 2021-05-24
  • 2022-12-23
  • 2021-11-09
  • 2022-01-30
  • 2022-12-23
  • 2022-12-23
猜你喜欢
  • 2021-04-05
  • 2021-12-10
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-12-23
相关资源
相似解决方案