Python Pandas Library to_csv function

27 June 2023 80 Reading time: 17 second

The to_csv function in the Pandas library is used to save a DataFrame as a CSV file. This function can be used to write the DataFrame to a file and export the data in CSV format.

import pandas as pd

# Save the DataFrame to a file named 'data.csv'
df.to_csv('data.csv', index=False)

Similar articles