Skip to content Skip to sidebar Skip to footer

Working With Json Nested In Json Using Python/pandas

I am trying to load JSON data using python, however, it looks like this: { 'instrument' : 'EUR_USD', 'granularity' : 'D', 'candles' : [ { 'time' : '

Solution 1:

You'll have to read the string using the json library first:

import json
data = json.loads(string)

And then you can extract the candles data from the resulting dictionary and build your DataFrame that way, e.g.:

candles_data = data.pop('candles')
df = pd.DataFrame(candles_data)
for k, v in data.iteritems():
    df[k] = v

Post a Comment for "Working With Json Nested In Json Using Python/pandas"