Categories
Python Answers

How to add Python Pandas data to an existing csv file?

Spread the love

Sometimes, we want to add Python Pandas data to an existing csv file.

In this article, we’ll look at how to add Python Pandas data to an existing csv file.

How to add Python Pandas data to an existing csv file?

To add Python Pandas data to an existing csv file, we can use the to_csv method.

For instance, we write

df.to_csv('my_csv.csv', mode='a', header=False)

to call to_csv with the csv file name, mode set to 'a' for append, and header set to False to avoid append the header to the file.

Conclusion

To add Python Pandas data to an existing csv file, we can use the to_csv method.

By John Au-Yeung

Web developer specializing in React, Vue, and front end development.

Leave a Reply

Your email address will not be published. Required fields are marked *