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.