pandas-dev / pandas

Flexible and powerful data analysis / manipulation library for Python, providing labeled data structures similar to R data.frame objects, statistical functions, and much more
https://pandas.pydata.org
BSD 3-Clause "New" or "Revised" License
43.19k stars 17.77k forks source link

BUG: json_normalize KeyError Key not found #59233

Open Opostol opened 1 month ago

Opostol commented 1 month ago

Pandas version checks

Reproducible Example

import pandas as pd
df = pd.json_normalize(data={'meta1':{'meta2':'meta_val'}, 'record1':{'record2':[{'rec1':'rec_val1'},{'rec1':'rec_val2'}]}}, meta=[['meta1','meta2']], record_path=['record1','record2'])

Issue Description

fact behaviour: KeyError: "Key 'meta2' not found.

Expected Behavior

expected df = rec1 meta1.meta2 0 rec_val1 meta_val 1 rec_val2 meta_val

Installed Versions

INSTALLED VERSIONS ------------------ commit : d9cdd2ee5a58015ef6f4d15c7226110c9aab8140 python : 3.12.4.final.0 python-bits : 64 OS : Windows OS-release : 10 Version : 10.0.19045 machine : AMD64 processor : AMD64 Family 16 Model 4 Stepping 2, AuthenticAMD byteorder : little LC_ALL : None LANG : None LOCALE : Russian_Russia.1251 pandas : 2.2.2 numpy : 2.0.0 pytz : 2024.1 dateutil : 2.9.0.post0 setuptools : None pip : 24.0 Cython : None pytest : None hypothesis : None sphinx : None blosc : None feather : None xlsxwriter : None lxml.etree : None html5lib : None pymysql : None psycopg2 : None jinja2 : None IPython : None pandas_datareader : None adbc-driver-postgresql: None adbc-driver-sqlite : None bs4 : None bottleneck : None dataframe-api-compat : None fastparquet : None fsspec : None gcsfs : None matplotlib : None numba : None numexpr : None odfpy : None openpyxl : None pandas_gbq : None pyarrow : None pyreadstat : None python-calamine : None pyxlsb : None s3fs : None scipy : None sqlalchemy : None tables : None tabulate : None xarray : None xlrd : None zstandard : None tzdata : 2024.1 qtpy : None pyqt5 : None
Opostol commented 1 month ago

issue raised to describe pull request https://github.com/pandas-dev/pandas/pull/59225