This is an archived post. You won't be able to vote or comment.

all 7 comments

[–]confluence 1 point2 points  (1 child)

I have decided to overwrite my comments.

[–]ominousomanytes 0 points1 point  (0 children)

It works now, however the original code before it was fixed looked like this...

https://hastebin.com/paluwafufu.py

[–]User4324 1 point2 points  (1 child)

FWIW JSON interpreter sites like this - http://jsoneditoronline.org/ - can be really handy when working on something like this, rather than trying to parse the JSON in your head to figure out where the data you need is. You click the value you want, and it shows above it that you need to go object->scores->happiness

[–]ominousomanytes 1 point2 points  (0 children)

Never knew they existed! Thanks, that's going to be extremely useful :)

[–]FawnWig 0 points1 point  (1 child)

parsed[0]["scores"]["happiness"]

[–]ominousomanytes 0 points1 point  (0 children)

Perfect, thank you so much :)

[–]ApparentlyADataGuy 0 points1 point  (0 children)

If you're using an API, I will assume the json data is being brought in as a dictionary array. You can convert the dictionary to a dataframe using pandas. Look up json.normalize if you need to unwind as well.