json-normalize

Python Pandas json_normalize with multiple lists of dicts

Python Pandas json_normalize with multiple lists of dicts Question: I’m trying to flatten a JSON file that was originally converted from XML using xmltodict(). There are multiple fields that may have a list of dictionaries. I’ve tried using record_path with meta data to no avail, but I have not been able to get it to …

Total answers: 1

problem when try to convert json file to dataframe with pandas

problem when try to convert json file to dataframe with pandas Question: I’m trying to read this local JSON file using pandas, but when I use the JSON NORMALIZE library to extract data from the JSON it throws me errors, I’ve tried many ways to do it but I don’t know if it’s a code …

Total answers: 2

How to normalise JSON data into seperate dataframe as rows and column in python

How to normalise JSON data into seperate dataframe as rows and column in python Question: I normalised one big nested JSON file but still getting JSON data in column refer to below example. My JSON data is as follows. data = [{ "task" : "jump", "taskid" : "task-001", "task-req" : [ { "taskid" : "task-001", …

Total answers: 1

Throwing error while performing Nested JSON Normalize using Pandas

Throwing error while performing Nested JSON Normalize using Pandas Question: I’m trying to normalize the JSON getting from GraphQL API and convert it to dataframe using json_normalize JSON [{ "node": { "organization": { "company": "System" }, "id": "15", "ip": "10.6.11.110", "name": "devce_name", "deviceClass": { "logicalName": "class OEM", "class": "class", "description": "OEM", "deviceCategory": { "name": "Unknown" …

Total answers: 1

json_normalize produces a KeyError when trying to extract certain attributes

json_normalize produces a KeyError when trying to extract certain attributes Question: Here is a subset of my json file: d = {‘data’: {‘questions’: [{‘id’: 6574, ‘text’: ‘Question #1’, ‘instructionalText’: ”, ‘minimumResponses’: 0, ‘maximumResponses’: None, ‘sortOrder’: 1, ‘answers’: [{‘id’: 362949, ‘text’: ‘Answer #1’, ‘parentId’: None}, {‘id’: 362950, ‘text’: ‘Answer #2’, ‘parentId’: None}, {‘id’: 362951, ‘text’: ‘Answer …

Total answers: 2

How to extract values in a JSON file into separate columns in a dataframe row

How to extract values in a JSON file into separate columns in a dataframe row Question: data = json.load(open("C:/Users/<username>/Downloads/one-day-run-record.json","rb")) df = pd.json_normalize(data)[["summaries", "tags.com.nike.weather", "tags.com.nike.name", "start_epoch_ms", "end_epoch_ms", "metrics"]] df My main goal is to extract the values in the metrics column. To understand the structure of that column you can use the line right below df.metrics[0] …

Total answers: 1

How to split a pandas column with a list of dicts into separate columns for each key

How to split a pandas column with a list of dicts into separate columns for each key Question: I’m analyzing Political Advertisements from Facebook, which is a dataset released here, by ProPublica. Here’s what I mean. I have an entire column of targets that I want to analyze but it’s formatted in a very inaccessible …

Total answers: 1

Unstacking json dictionaries in pandas

Unstacking json dictionaries in pandas Question: I’ve got one for ya. So I’m trying to unpack some proprietary data I’m getting from an api. for a reproducible example once I unpack the json data, I get a dictionary that looks like this temp = ([{"date" : "12/15/2020","order_id" : 1, "order_items" : [{"name" : "sponge", "quantity" …

Total answers: 1

How to download a nested JSON into a pandas dataframe

How to download a nested JSON into a pandas dataframe Question: Looking to sharpen my data science skills. I am practicing url data pulls from a sports site and the json file has multiple nested dictionaries. I would like to be able to pull this data to map my own custom form of the leaderboard …

Total answers: 4

How to json_normalize a column with NaNs

How to json_normalize a column with NaNs Question: This question is specific to columns of data in a pandas.DataFrame This question depends on if the values in the columns are str, dict, or list type. This question addresses dealing with the NaN values, when df.dropna().reset_index(drop=True) isn’t a valid option. Case 1 With a column of …

Total answers: 1