JSON to pandas DataFrame

后端 未结 11 1613
离开以前
离开以前 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:25

    The problem is that you have several columns in the data frame that contain dicts with smaller dicts inside them. Useful Json is often heavily nested. I have been writing small functions that pull the info I want out into a new column. That way I have it in the format that I want to use.

    for row in range(len(data)):
        #First I load the dict (one at a time)
        n = data.loc[row,'dict_column']
        #Now I make a new column that pulls out the data that I want.
        data.loc[row,'new_column'] = n.get('key')
    

提交回复
热议问题