Last active
December 24, 2020 14:26
-
-
Save winnydejong/a5b3f1f869eb9d75a2a32491b7af289e to your computer and use it in GitHub Desktop.
Handling jsons with Pandas
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# A shameless copy-paste from the lovely Zufanka, | |
# since I always forget to look here: | |
# https://gist.github.com/zufanka/39b8a55d707b3b4a2a4d369694739561#handling-jsons | |
import json | |
import requests | |
from pandas.io.json import json_normalize | |
r = requests.get("https://api.tenders.exposed/networks/58d77f85-bbc6-447d-a292-c3f17b7936b0/").text | |
data = json.loads(r) | |
# go down the tree as far as you need | |
data["network"]["nodes"] | |
# normalize that baby | |
pd.json_normalize(data["network"]["nodes"]) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment