I am new to Python. What I want to do is load the json Pandas forex price data file and make statistics with the data. I covered many topics in Pandas and parsing a json file. I want to transfer a json file with an extra value and a nested list to the Pandas data frame. I have a problem here.
I have a json file 'EUR_JPY_H8.json'
First I import the required library,
import pandas as pd
import json
from pandas.io.json import json_normalize
Then download the json file,
with open('EUR_JPY_H8.json') as data_file:
data = json.load(data_file)
I have a list below:
[{u'complete': True,
u'mid': {u'c': u'119.743',
u'h': u'119.891',
u'l': u'119.249',
u'o': u'119.341'},
u'time': u'1488319200.000000000',
u'volume': 14651},
{u'complete': True,
u'mid': {u'c': u'119.893',
u'h': u'119.954',
u'l': u'119.552',
u'o': u'119.738'},
u'time': u'1488348000.000000000',
u'volume': 10738},
{u'complete': True,
u'mid': {u'c': u'119.946',
u'h': u'120.221',
u'l': u'119.840',
u'o': u'119.888'},
u'time': u'1488376800.000000000',
u'volume': 10041}]
Then I pass the json_normalize list. Try to get the price, which is in the nested list below the middle
result = json_normalize(data,'time',['time','volume','complete',['mid','h'],['mid','l'],['mid','c'],['mid','o']])
But I got this result,
json_normalize output
"" .
. json_normalize. .
:
column =
index | time | volumn | completed | mid.h | mid.l | mid.c | mid.o