Question

I'm trying to use pandas.DataFrame.to_csv to export a DataFrame to a .csv file, however after running the following code there's no output:

collist = sve2_all.columns
path_d = 'C:\\Users\\Desktop\\From EPD'
sve2_all.to_csv('sve2_all', path = path_d, columns = collist)

Docs

Was it helpful?

Solution

I think what you are doing won't work as the path is not being used to set the destination path and resulting csv

This should work:

import os
path_d = 'C:\\Users\\Desktop\\From EPD'
sve2_all.to_csv(os.path.join(path_d, 'sve2_all.csv'))

Also, you are passing a string as the first parameter to to_csv which is probably confusing it also as it should be a fully qualified path or buffer for path_or_buf parameter.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top