Answers for "python list of dict to dataframe"

7

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')
Posted by: Guest on October-22-2020
1

python list of dict to dataframe

# Supposing d is your list of dicts, simply
df = pd.DataFrame(d)
# Note: this does not work with nested data
Posted by: Guest on April-23-2021
1

pandas to list of dicts

In [20]: timeit df.T.to_dict().values()
1000 loops, best of 3: 395 µs per loop

In [21]: timeit df.to_dict('records')
10000 loops, best of 3: 53 µs per loop
Posted by: Guest on August-21-2020

Code answers related to "python list of dict to dataframe"

Python Answers by Framework

Browse Popular Code Answers by Language