2

I have the following JSON data:

{
  "categories": [
    {
      "category_id": "11decadd",
      "name": "Com",
      "category_type": "Type",
      "position": 5,
      "vela_defined": True,
      "created_at": "2017-02-15 01:49:23 -0700",
      "updated_at": "2017-02-15 01:49:23 -0700"
    },
    {
      "category_id": "c7010763",
      "name": "none",
      "category_type": "EquipmentStatus",
      "position": 1,
      "vela_defined": True,
      "created_at": "2017-02-15 01:49:23 -0700",
      "updated_at": "2018-03-01 04:20:38 -0700"
    }
  ],
  "customizable_categories": [
    {
      "customizable_category_id": "435ae18b",
      "name": "NA",
      "category_id": "11decadd",
      "position": 1,
      "created_at": "2017-02-15 01:49:23 -0700",
      "updated_at": "2017-02-15 01:49:23 -0700"
    },
    {
      "customizable_category_id": "51e607d8",
      "name": "Third Party",
      "category_id": "fafab667",
      "position": 2,
      "created_at": "2017-02-15 01:49:23 -0700",
      "updated_at": "2017-02-15 01:49:23 -0700"
    }
  ],
  "equipment_category_status_sets": [

  ]
}

and Im attempting to turn it into 3x Pandas data frames (as named by the JSON top level entry)

But cant seem to get it to load at all. Any advice?

1 Answer 1

2

I think need dictionary comprehension with DataFrame contructor for dictionary of DataFrames:

dfs = {k:pd.DataFrame(v) for k, v in d.items()}

print (dfs['categories'])

  category_id     ...      vela_defined
0    11decadd     ...              True
1    c7010763     ...              True

[2 rows x 7 columns]

print (dfs['customizable_categories'])

  category_id            ...                             updated_at
0    11decadd            ...              2017-02-15 01:49:23 -0700
1    fafab667            ...              2017-02-15 01:49:23 -0700

[2 rows x 6 columns]

print (dfs['equipment_category_status_sets'])

Empty DataFrame
Columns: []
Index: []
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.