Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

BUG: record_prefix ignored when record_path is empty #62205

Open
Labels
Bug Needs TriageIssue that has not been reviewed by a pandas team member
@JensHeinrich

Description

Pandas version checks

  • I have checked that this issue has not already been reported.

  • I have confirmed this bug exists on the latest version of pandas.

  • I have confirmed this bug exists on the main branch of pandas.

Reproducible Example

import pandas as pd
_s = pd.Series([ {"k": f"{i}", "m": "q"} for i in range(5)
])
pd.json_normalize(_s,record_prefix="T")

Issue Description

The record_prefix is completely ignored and the resulting columns are note renamed.

 k m
0 0 q
1 1 q
2 2 q
3 3 q
4 4 q

The issue is in L517-L527 where a short cut is taken for speed.
One option to fix this would be to pass the record_prefix as prefix to nested_to_record.

This is hidden in the documentation example by using a positional argument for the record path

 >>> data = {"A": [1, 2]}
 >>> pd.json_normalize(data, "A", record_prefix="Prefix.")
 Prefix.0
 0 1
 1 2

Expected Behavior

The prefix should be applied (or an explicit warning be given)

 T.k T.m
0 0 q
1 1 q
2 2 q
3 3 q
4 4 q

Installed Versions

INSTALLED VERSIONS

commit : c888af6
python : 3.13.3
python-bits : 64
OS : Linux
OS-release : 6.14.0-28-generic
Version : #28-Ubuntu SMP PREEMPT_DYNAMIC Wed Jul 23 12:05:14 UTC 2025
machine : x86_64
processor : x86_64
byteorder : little
LC_ALL : None
LANG : en_US.UTF-8
LOCALE : en_US.UTF-8

pandas : 2.3.1
numpy : 2.3.2
pytz : 2025.2
dateutil : 2.9.0.post0
pip : 25.0
Cython : None
sphinx : None
IPython : 9.4.0
adbc-driver-postgresql: None
adbc-driver-sqlite : None
bs4 : 4.13.4
blosc : None
bottleneck : 1.5.0
dataframe-api-compat : None
fastparquet : 2024110
fsspec : 2025年5月1日
html5lib : 1.1
hypothesis : 6.135.20
gcsfs : 2025年5月1日
jinja2 : 3.1.6
lxml.etree : 5.4.0
matplotlib : 3.10.5
numba : None
numexpr : 2.11.0
odfpy : None
openpyxl : 3.1.5
pandas_gbq : 0.29.1
psycopg2 : None
pymysql : 1.4.6
pyarrow : 21.0.0
pyreadstat : 1.3.0
pytest : 8.4.1
python-calamine : None
pyxlsb : 1.0.10
s3fs : 2025年5月1日
scipy : 1.16.1
sqlalchemy : 2.0.43
tables : 3.10.2
tabulate : 0.9.0
xarray : 2025年6月1日
xlrd : 2.0.2
xlsxwriter : 3.2.5
zstandard : 0.23.0
tzdata : 2025.2
qtpy : 2.4.3
pyqt5 : None

Metadata

Metadata

Assignees

No one assigned

    Labels

    Bug Needs TriageIssue that has not been reviewed by a pandas team member

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions

        AltStyle によって変換されたページ (->オリジナル) /