Sebastian Goslin
Sebastian Goslin

Reputation: 497

Dataframe from dataframe of dictionaries

I have a dataframe of nested dictionaries:

   feature
0 {'A':'value1', 'B': 'value5', 'C':'value9'}
1 {'A':'value2', 'B': 'value6', 'C':'value10'}
2 {'A':'value3', 'B': 'value7', 'C':'value11'}
3 {'A':'value4', 'B': 'value8', 'C':'value12'}
.
.
.
n {'A':'valueN', 'B': 'valueM', 'C':'valueK'}

I would like to turn this into a new dataframe, they all have the same keys with different values so I would figure to use the keys as the new columns. Ideally it would look something like this:

    'A'      'B'      'C'
0 value1   value5    value9 
1 value2   value6    value10
2 value3   value7    value11
3 value4   value8    value12
.
.
.
n valueN   valueM    valueK

If anyone knows how to do this it would be great!

Upvotes: 1

Views: 36

Answers (1)

BENY
BENY

Reputation: 323226

You can do

pd.DataFrame(df.feature.tolist())

Upvotes: 2

Related Questions