I have a dict with output in this form:
response['candles'][0:2]
[{'complete': True,
'mid': {'c': '0.91535', 'h': '0.91535', 'l': '0.91535', 'o': '0.91535'},
'time': '2002-05-06T21:00:00.000000000Z',
'volume': 1},
{'complete': True,
'mid': {'c': '0.90435', 'h': '0.90435', 'l': '0.90435', 'o': '0.90435'},
'time': '2002-05-07T21:00:00.000000000Z',
'volume': 1}]
I can create a DataFrame easily that looks like this:
res = pd.DataFrame(response['candles'])
complete mid time volume
0 True {'o': '0.91535', 'h': '0.91535', 'l': '0.91535... 2002-05-06T21:00:00.000000000Z 1
1 True {'o': '0.90435', 'h': '0.90435', 'l': '0.90435... 2002-05-07T21:00:00.000000000Z 1
I can access 'mid' dict items like this:
response['candles'][0]['mid']['c']
'0.91535'
But how do I add columns in my DataFrame for each 'mid' item, instead of having a dict inside of the DataFrame? I want a column for ['mid']['o'], ['mid']['h'], and so on.
Thanks