JSON to pandas DataFrame(JSON到 pandas 数据框)
问题描述
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:
This gives me a data that looks like this:
when putting into as DataFrame here is what I get:
and here is what I want:
I'm not sure if this is possible, but mainly what I am looking for is a way to be able to put the elevation, latitude and longitude data together in a pandas dataframe (doesn't have to have fancy mutiline headers).
If any one can help or give some advice on working with this data that would be great! If you can't tell I haven't worked much with json data before...
EDIT:
This method isn't all that attractive but seems to work:
ends up dataframe having columns latitude, longitude, elevation
I found a quick and easy solution to what I wanted using json_normalize()
included in pandas 1.01
.
This gives a nice flattened dataframe with the json data that I got from the Google Maps API.
这篇关于JSON到 pandas 数据框的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!