Skip to content
Advertisement

How to convert to API response with multiple levels to dataframe in python

I have response from API call as shown below

JavaScript

How can I convert this into proper dataframe. I tried below code its creating the columns are properly. I want each element of the API response as seperate column. For eg. 'position': {'lat': 47.464699, 'lon': 8.54917} should be created dedicated column for lat and Lon seperately.

JavaScript

Loop Locations and get values and convert to dataframe

JavaScript

Advertisement

Answer

You can try json_normalize in loop with append for list of DataFrames and then join them by concat:

JavaScript

JavaScript
User contributions licensed under: CC BY-SA
3 People found this is helpful
Advertisement