from numpy import nan
d = {'E1': (((((['C', 'Me', 'Lans'], float(nan), ['3050', '55901']),
float(nan)),
float(nan)),
['2011-09-05 00:00:00', '3050-09-02 00:00:00']),
['2011-09-05 00:00:00', '3050-09-02 00:00:00']),
'E2': (((((['Can', 'Mar', 'Horns'], ['26D']),
['1001', '14086']),
float(nan),
['(100) 300-2345']),
['1001-09-02 00:00:00', '0100-09-02 00:00:00', '2011-19-26 00:00:00']),
['1001-09-02 00:00:00', '0100-09-02 00:00:00', '2011-19-26 00:00:00'])}
I have a messy looking dict d
. I would like the following output where d
is a list within a dictionary
d = {'E1': ['C', 'Me', 'Lans', float(nan),'3050', '55901', float(nan)), float(nan), '2011-09-05 00:00:00', '3050-09-02 00:00:00',
'2011-09-05 00:00:00', '3050-09-02 00:00:00'],
'E2': ['Can', 'Mar', 'Horns', '26D','1001', '14086', float(nan),'100 300-2345','1001-09-02 00:00:00', '0100-09-02 00:00:00', '2011-19-26 00:00:00',
'1001-09-02 00:00:00', '0100-09-02 00:00:00', '2011-19-26 00:00:00']}
I've tried the code Flatten nested dictionaries, compressing keys but it doesn't give me quite what I am looking for. Can any body help?