import pandas as pd
# Dataframe example
df = pd.DataFrame({'col_A':[1,5,7,8],'col_B':[9,7,4,3]})
# Save dataframe as csv file in the current folder
df.to_csv('filename.csv', index = False, encoding='utf-8') # False: not include index
print(df)
#Note: to Save dataframe as csv file in other folder use instead:
'''
df.to_csv('Path/filename.csv', index = False, encoding='utf-8') # Replace 'Path' by the wanted folder
''';
df = pd.read_csv('data.csv')
df.to_csv(file_name, sep=' ')
df.to_csv(file_name, sep=' ', encoding='utf-8')
df.to_csv(file_name, sep=' ', encoding='utf-8')
df.to_csv(file_name, sep=' ')
df.to_csv("name.csv")
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
df.to_csv(r'Path where you want to store the exported CSV fileFile Name.csv')
df.to_csv(r'Path where you want to store the exported CSV fileFile Name.csv', index = False)
import pandas as pd
data = {'Product': ['Desktop Computer','Tablet','Printer','Laptop'],
'Price': [850,200,150,1300]
}
df = pd.DataFrame(data, columns= ['Product', 'Price'])
print (df)