Skip to content

DOC: description of record_prefix param for json_normalize is wrong #54121

Open
@wjandrea

Description

@wjandrea

Pandas version checks

  • I have checked that the issue still exists on the latest versions of the docs on main here

Location of the documentation

https://pandas.pydata.org/docs/dev/reference/api/pandas.json_normalize.html

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

Documentation problem

The description implies record_prefix is taken as a boolean, but as said above, it's actually a string. There's an example below that shows how it actually behaves:

>>> 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.

Suggested fix for documentation

I might suggest:

record_prefix : str, default None
If provided, prefix records with this string, e.g. foo.bar.field if record_prefix is 'foo.bar.'.


BTW, I think meta_prefix also has the same problem, but I don't have an example to test it on.

Metadata

Metadata

Assignees

No one assigned

    Labels

    DocsIO JSONread_json, to_json, json_normalize

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions