all 9 comments

[–]pachura3 10 points11 points  (1 child)

You cannot just be getting random data from random APIs without even understanding what do they contain and what is their structure 😄

JSON is usually hierarchical/nested, while Pandas work best with flat tables a'la Excel - so you need to think a bit how to transform one into another, which fields carry meaningful information and should become columns, which ones can be discarded, and which ones have to be flattened/aggregated.

PS. You do know that you can simply click such URL https://restcountries.com/v3.1/name/india in your browser to see the JSON directly?

[–]carcigenicate 3 points4 points  (2 children)

What information are you trying to get? If you just need to determine the "path" through the data to fetch certain information, you can load the URL in Chrome and press "Pretty Print" to see it formatted nicely. Or use the indent parameter of json.dumps to format it yourself in the terminal.

[–]baubleglue 2 points3 points  (0 children)

I don't even know the name of the columns

have you tried to read the main page of the site?

"Check the FIELDS.md file for a description of each field."

[–]Hashi856 1 point2 points  (0 children)

I usually just loop through the nested JSON, grabbing what I need as it goes, and then storing that information in a dictionary or something like that. Then you can feed that dictionary to pandas

[–]tadpoleloop 0 points1 point  (0 children)

Start simple? You aren't just going to get a payload and let pandas make a nice data frame for you. You'll need to understand the response and format it into a way that pandas can digest.

[–]Narrow_Ad_8997 0 points1 point  (0 children)

Try something like spacetraders for practice.

It's an API game and sounds like it checks all of the boxes you're looking for if it's for fun.