Skip to content

BUG: json_normalize KeyError Key not found #59233

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
3 tasks done
Opostol opened this issue Jul 11, 2024 · 3 comments
Closed
3 tasks done

BUG: json_normalize KeyError Key not found #59233

Opostol opened this issue Jul 11, 2024 · 3 comments
Labels
Bug IO JSON read_json, to_json, json_normalize Needs Info Clarification about behavior needed to assess issue

Comments

@Opostol
Copy link

Opostol commented Jul 11, 2024

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
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 : d9cdd2e
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 Opostol added Bug Needs Triage Issue that has not been reviewed by a pandas team member labels Jul 11, 2024
@Opostol
Copy link
Author

Opostol commented Jul 11, 2024

issue raised to describe pull request
#59225

@rhshadrach
Copy link
Member

The current design requires meta fields to be part of the records. The example in the OP does not meet this requirement. Am I right in saying that you desire to be able to specify meta fields that are not part of the records?

@rhshadrach rhshadrach added IO JSON read_json, to_json, json_normalize Needs Info Clarification about behavior needed to assess issue and removed Needs Triage Issue that has not been reviewed by a pandas team member labels Nov 5, 2024
@rhshadrach
Copy link
Member

Closing in favor of #60254

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug IO JSON read_json, to_json, json_normalize Needs Info Clarification about behavior needed to assess issue
Projects
None yet
Development

No branches or pull requests

2 participants