Set File_Path for to_csv() in Pandas

前端 未结 1 1864
既然无缘
既然无缘 2020-12-24 09:53
funded=r\'C:\\Users\\hill\\Desktop\\wheels\\Leads(1).csv\'
funded= read_csv(funded)
funded=DataFrame(funded)
path=\'C:\\Users\\hvill\\Destop\\ \'
funded.to_csv(path,         


        
相关标签:
1条回答
  • 2020-12-24 10:29

    You need to either escape your back slashes or better use a raw string:

    path='C:\\Users\\hvill\\Destop\\'
    

    or better as fewer characters:

    path=r'C:\Users\hvill\Destop\'
    

    I also think you want to do this when saving:

    funded.to_csv(path+'greenl.csv')
    

    To avoid the ambiguity and allow portability of your code you can use this:

    import os
    funded.to_csv(os.path.join(path,r'green1.csv'))
    

    this will append your csv name to your destination path correctly

    0 讨论(0)
提交回复
热议问题