Skip to content
Advertisement

Flatting a JSON file into Pandas Dataframe in Python

I have the json in this format:

JavaScript

I want it to be in a dataframe format where each of the three field names are separate rows. Where one row has a column(e.g “format”) where others are blank should be assumed to be NULL.

I have tried to use the flatten_json function which I found on here, but doesn’t work as expected but will still include here:

JavaScript

Additional Complexity JSON:

JavaScript

Advertisement

Answer

With

JavaScript

this

JavaScript

results in

JavaScript

Is that your goal?

If you want the keys of data["fields"] as index:

JavaScript

or

JavaScript

both result in

JavaScript

With

JavaScript

you could either do

JavaScript

or

JavaScript

with a result like (column positions may differ)

JavaScript
User contributions licensed under: CC BY-SA
3 People found this is helpful
Advertisement