I am trying to extract data from API and write into a Pandas Dataframe so that I can do some transformations .
import requests
headers = {
'Authorization': 'Api-Key',
}
params = (
('locodes', 'PLWRO,DEHAM'),
)
response = requests.get('https://api.xxx.com/weather/v1/forecasts', headers=headers, params=params)
The result of the API Call
response.text
'{"results":[{"place":{"type":"locode","value":"PLWRO"},"measures":[{"ts":1571896800000,"t2m":10.72,"t_min":10.53,"t_max":11.99,"wspd":8,"dir":"SE","wgust":12,"rh2m":87,"prsmsl":1012,"skcover":"clear","precip":0.0,"snowd":0,"thunderstorm":"N","fog":"H"}]},{"place":{"type":"locode","value":"DEHAM"},"measures":[{"ts":1571896800000,"t2m":10.79,"t_min":10.3,"t_max":10.9,"wspd":13,"dir":"ESE","wgust":31,"rh2m":97,"prsmsl":1008,"skcover":"partly_cloudy","precip":0.0,"snowd":0,"thunderstorm":"N","fog":"H"}]}]}'
When Try to into pandas dataframe its not coming in the correct format.
import pandas as pd
import io
urlData = response.content
rawData = pd.read_csv(io.StringIO(urlData.decode('utf-8')))
How can I have values populating correctly under each header.