Search code examples
pythonexport-to-csv

Is there a way to export a dataset I made in python to my computer?


I used two databases for a project I am working on in python and merged them on a common key in my code. I was wondering if there was a way to save the merged database in a .csv file on my computer so I can send it to someone or just look it at myself.

This is the code I used to merge them.

db1_in = pd.read_csv('path to ---> database1.csv', low_memory=False)
db1_in['id']=db1_in['id'].astype(int)
db2_in = pd.read_csv('path to ---> database2.csv', low_memory=False)

#combine the two databases based on their id
combined = pd.merge(db1_in, db2_in, on='id')

I just want to take that combined file and save it to my Mac as combined.csv and email it to someone or use it as one in another project.


Solution

  • you can do combined.to_csv('<the file name you want to use>.csv') here is a reference for you