报错的意思是说,没有对应的路径的文件夹。
虽然能够生成文件,但是必须要有生成的文件夹。

常用的方法是先判断是否文件夹存在,如果不存在,则先创建对应的文件夹。

import os

outname = 'name.csv'

outdir = './dir'
if not os.path.exists(outdir):
    os.mkdir(outdir)

fullname = os.path.join(outdir, outname)    

df.to_csv(fullname)

参考链接: https://stackoverflow.com/questions/47143836/pandas-dataframe-to-csv-raising-ioerror-no-such-file-or-directory

相关文章:

  • 2021-08-22
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-01-02
  • 2022-02-18
  • 2022-12-23
猜你喜欢
  • 2021-11-20
  • 2021-06-07
  • 2021-08-03
  • 2022-02-14
  • 2021-09-28
  • 2022-12-23
  • 2022-12-23
相关资源
相似解决方案