Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR PYTHON

dataframe to list of dicts

df = pd.DataFrame({'Name': ['John', 'Sara','Peter','Cecilia'],
                   'Age': [38, 47,63,28],
                  'City':['Boston', 'Charlotte','London','Memphis']})

datadict = df.to_dict('records')
 
PREVIOUS NEXT
Tagged: #dataframe #list #dicts
ADD COMMENT
Topic
Name
8+1 =