How to convert nested dictionary into a 2D table
data[0] is a collection of table rows
data[0][0] is a table row,
key:year is the column name,
key:values is the values in the column.
I want to recover the data[0] into tablular form in Pandas dataframe.
I found the json_normalize may help, but not knowing how to do it.
any suggestions ?
Expected format
Raw data in dictionary
(Pdb++) data[0]
[{u'values': [{u'Actual': u'(0.2)'}, {u'Upper End of Range': u'-'}, {u'Upper End of Central Tendency': u'-'}, {u'Lower End of Central Tendency': u'-'}, {u'Lower End of Range': u'-'}], u'year': u'2009'}, {u'values': [{u'Actual': u'2.8'}, {u'Upper End of Range': u'-'}, {u'Upper End of Central Tendency': u'-'}, {u'Lower End of Central Tendency': u'-'}, {u'Lower End of Range': u'-'}], u'year': u'2010'}, {u'values': [{u'Actual': u'2.0'}, {u'Upper End of Range': u'-'}, {u'Upper End of Central Tendency': u'-'}, {u'Lower End of Central Tendency': u'-'}, {u'Lower End of Range': u'-'}], u'year': u'2011'}, {u'values': [{u'Actual': u'2.0'}, {u'Upper End of Range': u'-'}, {u'Upper End of Central Tendency': u'-'}, {u'Lower End of Central Tendency': u'-'}, {u'Lower End of Range': u'-'}], u'year': u'2012'}, {u'values': [{u'Actual': u'2.5'}, {u'Upper End of Range': u'-'}, {u'Upper End of Central Tendency': u'-'}, {u'Lower End of Central Tendency': u'-'}, {u'Lower End of Range': u'-'}], u'year': u'2013'}, {u'values': [{u'Actual': u'-'}, {u'Upper End of Range': u'3.0'}, {u'Upper End of Central Tendency': u'3.0'}, {u'Lower End of Central Tendency': u'2.8'}, {u'Lower End of Range': u'2.1'}], u'year': u'2014'}, {u'values': [{u'Actual': u'-'}, {u'Upper End of Range': u'3.5'}, {u'Upper End of Central Tendency': u'3.2'}, {u'Lower End of Central Tendency': u'3.0'}, {u'Lower End of Range': u'2.2'}], u'year': u'2015'}, {u'values': [{u'Actual': u'-'}, {u'Upper End of Range': u'3.4'}, {u'Upper End of Central Tendency': u'3.0'}, {u'Lower End of Central Tendency': u'2.5'}, {u'Lower End of Range': u'2.2'}], u'year': u'2016'}, {u'values': [{u'Actual': u'-'}, {u'Upper End of Range': u'2.4'}, {u'Upper End of Central Tendency': u'2.3'}, {u'Lower End of Central Tendency': u'2.2'}, {u'Lower End of Range': u'1.8'}], u'year': u'Longer Run'}]
(Pdb++) data[0][0]
{u'values': [{u'Actual': u'(0.2)'}, {u'Upper End of Range': u'-'}, {u'Upper End of Central Tendency': u'-'}, {u'Lower End of Central Tendency': u'-'}, {u'Lower End of Range': u'-'}], u'year': u'2009'}
Maybe to change the JSON schema will be a better solution ?
if so, what kind of NEW JSON schema design is better for the kind of table data. thanks