I run the following code and it outputs the json below.
import requests
url="xxxx"
r = requests.request("GET", url, headers=headers, data=payload)
j=r.json()
recs = j['collection']
Json
{'stationCode': 'NB001',
'summaries': [{'period': {'year': 2017}, 'rainfall': 449},
{'period': {'year': 2018}, 'rainfall': 352.4},
{'period': {'year': 2019}, 'rainfall': 253.2},
{'period': {'year': 2020}, 'rainfall': 283},
{'period': {'year': 2021}, 'rainfall': 104.2}]},{'stationCode': 'NA003','summaries': [{'period': {'year': 2019}, 'rainfall': 58.2},{'period': {'year': 2020}, 'rainfall': 628.2},{'period': {'year': 2021}, 'rainfall': 120}]}
I need this output as follows into a table
Tried the following and I still could extract table with multiple added lines but just wondered if there was a faster way
df = json_normalize(recs)
df
