Skip to content Skip to sidebar Skip to footer

How I Can Save Each Column Of Dataframe To Separated Column In Csv File?

when I save my dataframe to csv file, It is combined in one column, I want each column of data frame to appear in separated column in CSV file, this is the code df.to_csv(r'myData

Solution 1:

In a csv file, each row is a separate line, and in this row, the different columns are separated by comma.

So

`0,2019-09-28 08:58:13,"The TRUTH about Carbon Dioxide"` 

is a row of the data frame, not a column. The columns are still separated by comma in the csv file.

Solution 2:

OK the answer is simply changing sep=',' to sep=';'

Post a Comment for "How I Can Save Each Column Of Dataframe To Separated Column In Csv File?"