create and save dataframe to csv

PHOTO EMBED

Wed Jul 14 2021 15:10:14 GMT+0000 (Coordinated Universal Time)

Saved by @QuinnFox12 #python #textpreprocessing #nlp #dataframe #pandas #save #export

import pandas as pd

data = {'Product': ['Desktop Computer','Tablet','Printer','Laptop'],
        'Price': [850,200,150,1300]
        }

df = pd.DataFrame(data, columns= ['Product', 'Price'])

df.to_csv(r'Path where you want to store the exported CSV file\File Name.csv')
# df.to_csv('file_name.csv', encoding='utf-8', index=False)
print (df)

data[['column1','column2','column3',...]].to_csv('fileNameWhereYouwantToWrite.csv')
     
df = pd.DataFrame()
for i in range():
	#....
	df.appen(text)
content_copyCOPY