Writing a pandas DataFrame to CSV file

前端 未结 7 1710
死守一世寂寞
死守一世寂寞 2020-11-22 11:07

I have a dataframe in pandas which I would like to write to a CSV file. I am doing this using:

df.to_csv(\'out.csv\')

And getting the error

相关标签:
7条回答
  • 2020-11-22 11:34

    To delimit by a tab you can use the sep argument of to_csv:

    df.to_csv(file_name, sep='\t')
    

    To use a specific encoding (e.g. 'utf-8') use the encoding argument:

    df.to_csv(file_name, sep='\t', encoding='utf-8')
    
    0 讨论(0)
提交回复
热议问题