How can I parse the following data structure:
data = {0: None,
1: [OrderedDict([('N', '1192'),
('Date', '2009-10-08T00:00:00'),
('Rule', '0'),
('N_Dip', '0'),
('Leg',
OrderedDict([('Id', '33'),
('Name', 'Ports'),
('Type',
OrderedDict([('Id', '2'),
('Name', 'Dip')]))])),
('Id', '69')]),
OrderedDict([('N', '382'),
('Date', '2012-11-23T00:00:00'),
('Rule', '0'),
('N_Dip', '0'),
('Leg',
OrderedDict([('Id', '33'),
('Name', 'Ports'),
('Type',
OrderedDict([('Id', '2'),
('Name', 'Dip')]))])),
('Id', '70')])],
2: None,
3: None,
4: None,
5: OrderedDict([('N', '5º'),
('Article', '36º'),
('Date', '0001-01-01T00:00:00'),
('Rule', '0'),
('N_Dip', '0'),
('Leg',
OrderedDict([('Id', '7'),
('Name', 'DEVA'),
('Type',
OrderedDict([('Id', '1'),
('Name', 'Code')]))])),
('Id', '127')]),
6: None,
7: None}
into a pandas DataFrame with the columns (not necessarily in this order):
N | Date | Rule | N_Dip | Leg_Id | Leg_Name | Leg_Type | Leg_Type_Id | Leg_Type_Name | Leg_Type_Name | Id | Article
and where each dict key (each number) becomes a row?
Example desired output:
I'm not seeing how to solve this without the use of multilevel indexing, but if you have another idea, feel free.
I don't care about the order of the columns.
Thanks in advance,
EDITS:
- corrected "Nome" to "Name" (18/06/2021);
- added desired output (18/06/2021).
