Skip to content Skip to sidebar Skip to footer

Flatten Pandas Dataframe From Nested Json List

perhaps somebody could help me. I tried to flat the following ist into a pandas dataframe: [{u'_id': u'2', u'_index': u'list', u'_score': 1.4142135, u'_source': {u'name': u'

Solution 1:

Use json_normalize:

from pandas.io.json import json_normalize  

df = json_normalize(data)
print (df)
  _id _index    _score _source.dat _source.name _type
0   2   list  1.414214         NaN        name3   doc
1   5   list  1.414214  2016-12-12        name2   doc
2   1   list  1.414214         NaN        name1   doc

Post a Comment for "Flatten Pandas Dataframe From Nested Json List"