I've dictionary in this format:
d = {'key_1':['item_1','item_2','item_3'],'key_2':['item_1','item_2','item_3'],}
And I need to save it in csv format.
I did this:
import csv
with open('output.csv', 'w') as f:
w = csv.DictWriter(f, d.keys())
w.writeheader()
w.writerow(d)
But I get only one row for the header and one more row for the items, I want each item in a different row as what you get with pandas.
df = pd.DataFrame(d)
df.to_csv('output.csv')
But of course in this case without using pandas.