Save Pandas Dataframe to .csv file

Best way is to use Panda’s to_csv() built-in function

df.to_csv('filename', index=False)

Don’t forget to pass index=False as a second parameter if you don’t want index row saved as a column (in other words use it if you don’t want duplicated index when opening the file again).

By the way, you can also withhold column names when exporting csv with header=False:

df.to_csv('filename', index=False, header=False)
0 0 votes
Article Rating
Subscribe
Notify of
guest
0 Comments
Inline Feedbacks
View all comments
0
Would love your thoughts, please comment.x
()
x