pandas 1.4.2

ParametersReturns
_json_normalize(data: 'dict | list[dict]', record_path: 'str | list | None' = None, meta: 'str | list[str | list[str]] | None' = None, meta_prefix: 'str | None' = None, record_prefix: 'str | None' = None, errors: 'str' = 'raise', sep: 'str' = '.', max_level: 'int | None' = None) -> 'DataFrame'
deprecated

Use :None:None:`pandas.json_normalize` instead.

Parameters

data : dict or list of dicts

Unserialized JSON objects.

record_path : str or list of str, default None

Path in each object to list of records. If not passed, data will be assumed to be an array of records.

meta : list of paths (str or list of str), default None

Fields to use as metadata for each record in resulting table.

meta_prefix : str, default None

If True, prefix records with dotted (?) path, e.g. foo.bar.field if meta is ['foo', 'bar'].

record_prefix : str, default None

If True, prefix records with dotted (?) path, e.g. foo.bar.field if path to records is ['foo', 'bar'].

errors : {'raise', 'ignore'}, default 'raise'

Configures error handling.

sep : str, default '.'

Nested records will generate names separated by sep. e.g., for sep='.', {'foo': {'bar': 0}} -> foo.bar.

max_level : int, default None

Max number of levels(depth of dict) to normalize. if None, normalizes all levels.

versionadded

Returns

frame : DataFrame
Normalize semi-structured JSON data into a flat table.

Normalize semi-structured JSON data into a flat table.

Examples

This example is valid syntax, but we were not able to check execution
>>> data = [
...  {"id": 1, "name": {"first": "Coleen", "last": "Volk"}},
...  {"name": {"given": "Mark", "family": "Regner"}},
...  {"id": 2, "name": "Faye Raker"},
... ]
... pd.json_normalize(data) id name.first name.last name.given name.family name 0 1.0 Coleen Volk NaN NaN NaN 1 NaN NaN NaN Mark Regner NaN 2 2.0 NaN NaN NaN NaN Faye Raker
This example is valid syntax, but we were not able to check execution
>>> data = [
...  {
...  "id": 1,
...  "name": "Cole Volk",
...  "fitness": {"height": 130, "weight": 60},
...  },
...  {"name": "Mark Reg", "fitness": {"height": 130, "weight": 60}},
...  {
...  "id": 2,
...  "name": "Faye Raker",
...  "fitness": {"height": 130, "weight": 60},
...  },
... ]
... pd.json_normalize(data, max_level=0) id name fitness 0 1.0 Cole Volk {'height': 130, 'weight': 60} 1 NaN Mark Reg {'height': 130, 'weight': 60} 2 2.0 Faye Raker {'height': 130, 'weight': 60}

Normalizes nested data up to level 1.

This example is valid syntax, but we were not able to check execution
>>> data = [
...  {
...  "id": 1,
...  "name": "Cole Volk",
...  "fitness": {"height": 130, "weight": 60},
...  },
...  {"name": "Mark Reg", "fitness": {"height": 130, "weight": 60}},
...  {
...  "id": 2,
...  "name": "Faye Raker",
...  "fitness": {"height": 130, "weight": 60},
...  },
... ]
... pd.json_normalize(data, max_level=1) id name fitness.height fitness.weight 0 1.0 Cole Volk 130 60 1 NaN Mark Reg 130 60 2 2.0 Faye Raker 130 60
This example is valid syntax, but we were not able to check execution
>>> data = [
...  {
...  "state": "Florida",
...  "shortname": "FL",
...  "info": {"governor": "Rick Scott"},
...  "counties": [
...  {"name": "Dade", "population": 12345},
...  {"name": "Broward", "population": 40000},
...  {"name": "Palm Beach", "population": 60000},
...  ],
...  },
...  {
...  "state": "Ohio",
...  "shortname": "OH",
...  "info": {"governor": "John Kasich"},
...  "counties": [
...  {"name": "Summit", "population": 1234},
...  {"name": "Cuyahoga", "population": 1337},
...  ],
...  },
... ]
... result = pd.json_normalize(
...  data, "counties", ["state", "shortname", ["info", "governor"]]
... )
... result name population state shortname info.governor 0 Dade 12345 Florida FL Rick Scott 1 Broward 40000 Florida FL Rick Scott 2 Palm Beach 60000 Florida FL Rick Scott 3 Summit 1234 Ohio OH John Kasich 4 Cuyahoga 1337 Ohio OH John Kasich
This example is valid syntax, but we were not able to check execution
>>> data = {"A": [1, 2]}
... pd.json_normalize(data, "A", record_prefix="Prefix.") Prefix.0 0 1 1 2

Returns normalized data with columns prefixed with the given string.

See :

Local connectivity graph

Hover to see nodes names; edges to Self not shown, Caped at 50 nodes.

Using a canvas is more power efficient and can get hundred of nodes ; but does not allow hyperlinks; , arrows or text (beyond on hover)

SVG is more flexible but power hungry; and does not scale well to 50 + nodes.

All aboves nodes referred to, (or are referred from) current nodes; Edges from Self to other have been omitted (or all nodes would be connected to the central node "self" which is not useful). Nodes are colored by the library they belong to, and scaled with the number of references pointing them


File: /pandas/io/json/_normalize.py#241
type: <class 'function'>
Commit: