xxxxxxxxxx
import pandas as pd
# Assuming you have a dataframe called 'df'
df.to_csv('output.csv', index=False)
xxxxxxxxxx
df.to_csv (r'C:\Users\John\Desktop\export_dataframe.csv', index = None, header=True)
xxxxxxxxxx
new_df.to_csv("data.csv",index=False)
#if want to transpose and save it then
new_df.T.to_csv("data.csv",index=False)
#If this works, you can buy me a coffee.
# https://www.buymeacoffee.com/eyolve
xxxxxxxxxx
import pandas as pd
df = pd.DataFrame({'A': [1, 2, 3], 'B': [4, 5, 6]})
df.to_csv('my_data.csv', index=False)
xxxxxxxxxx
>>> df = pd.DataFrame({'name': ['Raphael', 'Donatello'],
'mask': ['red', 'purple'],
'weapon': ['sai', 'bo staff']})
>>> df.to_csv(index=False)