JSON to pandas DataFrame

后端 未结 11 1771
离开以前
离开以前 2020-11-22 05:46

What I am trying to do is extract elevation data from a google maps API along a path specified by latitude and longitude coordinates as follows:

from urllib2         


        
11条回答
  •  感动是毒
    2020-11-22 06:13

    billmanH's solution helped me but didn't work until i switched from:

    n = data.loc[row,'json_column']
    

    to:

    n = data.iloc[[row]]['json_column']
    

    here's the rest of it, converting to a dictionary is helpful for working with json data.

    import json
    
    for row in range(len(data)):
        n = data.iloc[[row]]['json_column'].item()
        jsonDict = json.loads(n)
        if ('mykey' in jsonDict):
            display(jsonDict['mykey'])
    

提交回复
热议问题