I have response from API call as shown below
(data = json.loads(response.text)
{'items': [{'start': '2021-03-21T00:00:00.000',
'end': '2021-03-31T00:00:00.000',
'location': {'code': None,
'position': {'lat': 47.464699, 'lon': 8.54917},
'country_code': None},
'source': 'geoeditor',
'title': 'test 25.03.2021',
'body': 'test description',
'severity': None,
'category': None,
'relatedEntities': None,
'relevant': None,
'raw': {'active': True,
'id': 82482150,
'layerId': 'disruption_il',
'locationType': 'POINT',
'name': 'New Location',
'changed': '2021-03-25T20:49:51Z',
'groupId': None,
'identifiers': [{'name': 'ref_id',
'value': '9ded7375-bea2-4466-96a9-fd5c42f9a562'}],
'properties': {'title': 'test 25.03.2021',
'source': 'disruption_news_event',
'to_date': '2021-03-31',
'relevant': 'true',
'from_date': '2021-03-21',
'description': 'test description'},
'relationships': [{'referenceIdentifierValue': 'ZRH',
'relationshipId': 'event_impacts_airport',
'referenceLayerId': 'airport_status',
'referenceIdentifierName': 'iata_code'}]}}],
'totalItems': 1,
'errors': []}
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.
df =pd.json_normalize(data)
df1= pd.DataFrame(df1)
Loop Locations and get values and convert to dataframe
location
SIN
ZRH
import requests
headers = {
'accept': 'application/json',
'Authorization': 'Api-Key',
'Content-Type': 'application/json',
}
response = requests.get('https://risk.dev.logindex.com/il/risk/location/SIN', headers=headers)