Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR PYTHON

dict to csv keys as rows and subkey as columns in python

import pandas as pd
dic = {"Location1":{"a":1,"b":2,"c":3},"Location2":{"a":4,"b":5,"c":6}, "Location3":{'e':7,'f':8, 'g':9, 'h':10}, "Location4":{'e': 2, 'f': 3, 'g': 4, 'h': 5}}
pd.DataFrame.from_dict(dic, orient='index').to_csv('temp.csv')
Source by stackoverflow.com #
 
PREVIOUS NEXT
Tagged: #dict #csv #keys #rows #subkey #columns #python
ADD COMMENT
Topic
Name
5+8 =