I have called some data from the World Health Organisation in JSON format, I would like to read this into a Pandas DataFrame.
I have called this from this page: WHO Measles First Dose Rate
{u'dimension': [{u'display': u'Indicator', u'label': u'GHO'},
{u'display': u'PUBLISH STATES', u'label': u'PUBLISHSTATE'},
{u'display': u'Year', u'label': u'YEAR'},
{u'display': u'WHO region', u'label': u'REGION'},
{u'display': u'World Bank income group', u'label': u'WORLDBANKINCOMEGROUP'},
{u'display': u'Country', u'label': u'COUNTRY'}],
u'fact': [{u'Value': u'25',
u'dim': {u'COUNTRY': u'Afghanistan',
u'GHO': u'Measles-containing-vaccine first-dose (MCV1) immunization coverage among 1-year-olds (%)',
u'PUBLISHSTATE': u'Published',
u'REGION': u'Eastern Mediterranean',
u'WORLDBANKINCOMEGROUP': u'Low-income',
u'YEAR': u'1993'}},
{u'Value': u'57',
u'dim': {u'COUNTRY': u'Afghanistan',
u'GHO': u'Measles-containing-vaccine first-dose (MCV1) immunization coverage among 1-year-olds (%)',
u'PUBLISHSTATE': u'Published',
u'REGION': u'Eastern Mediterranean',
u'WORLDBANKINCOMEGROUP': u'Low-income',
u'YEAR': u'2013'}},
{u'Value': u'62',
u'dim': {u'COUNTRY': u'Angola',
u'GHO': u'Measles-containing-vaccine first-dose (MCV1) immunization coverage among 1-year-olds (%)',
u'PUBLISHSTATE': u'Published',
u'REGION': u'Africa',
u'WORLDBANKINCOMEGROUP': u'Upper-middle-income',
u'YEAR': u'1996'}},
{u'Value': u'94',
u'dim': {u'COUNTRY': u'Andorra',
u'GHO': u'Measles-containing-vaccine first-dose (MCV1) immunization coverage among 1-year-olds (%)',
u'PUBLISHSTATE': u'Published',
u'REGION': u'Europe',
u'WORLDBANKINCOMEGROUP': u'High-income',
u'YEAR': u'2005'}},
{u'Value': u'34',
u'dim': {u'COUNTRY': u'United Arab Emirates',
u'GHO': u'Measles-containing-vaccine first-dose (MCV1) immunization coverage among 1-year-olds (%)',
u'PUBLISHSTATE': u'Published',
u'REGION': u'Eastern Mediterranean',
u'WORLDBANKINCOMEGROUP': u'High-income',
u'YEAR': u'1980'}},
I have tried
#Setting Up and loading JSON into object ready to turn into dataframe
url = "http://apps.who.int/gho/athena/data/GHO/WHS8_110.json?profile=simple&filter=COUNTRY:*"
response = requests.get(url)
response_json = response.content
json.loads(response_json)
whoDataSetVaccinationRate = json.loads(response_json)
#Attempt to load JSON Data into Pandas Dataframe
whoDataSetVaccinationRateDF = pd.DataFrame(whoDataSetVaccinationRate['fact']
, columns=['COUNTRY', 'YEAR','REGION'])
whoDataSetVaccinationRateDF
And that seems to read - but I only get NaN values in the dataframe for COUNTRY and YEAR:
And I realise I want it laid out differently in the dataframe anyway - and I'm not sure how to call that. This is how I want my dataframe to look: