-
-
Notifications
You must be signed in to change notification settings - Fork 17.6k
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
json_normalize should raise when record_path doesn't point to an array #26284
Comments
pls post a reproducible example and version as the template indicates |
I am trying to import deeply nested json into pandas (v0.24.2) using json_normalize and coming across a few inconsistencies which I am struggling to resolve. An example json is as follows, which is inconstantly formatted as indicated by Missing keyEB
The following code gives the expected behavior of json_normalize, extracting the correctly normalised data : First level json correctly normalized
Second level KeyC correctly normalized
Fourth level keyCBC correctly normalized
However, other branches seem to be inconsistently normalized.
and the following completely bombs with a keyword error because of the missing keyEB
Is this expected behaviour from jsons_normalize ? |
So As to the second issue you've pointed out there currently isn't support for ignoring errors for items specified in the record_path. If that's something you would like to request should probably open as a separate issue and we can repurpose this one for better error handling with the issue described above |
Thanks for the feedback. For the second issue I will raise a separate issue as you suggested. |
Not sure I see a need for this either. If I had to guess its simply a byproduct of the fact that iterating over a dict will return its keys
Yea I can see that. I'm not sure if the JSON spec makes any distinction between a single object and an array containing a single object that would dictate behavior, but if not I think we'd be open to it if you want to try a PR! |
Improves robustness of json_normalize for inconsistently formatted json pandas-dev#26284
Adds new tests for deeply nested json which is inconsistently formatted pandas-dev#26284
Hey, i would like to work on this issue. Has it already being resolved? |
Not by me. I recoded normalize.py and got it working for my specific need off-line. Never quite found the time to re-code in a generalised form for approval into the main branch. |
There seems to be odd behaviour with json_normalize, specifically when json keys are inconsistently formatted.
json_normalize throws a keyword error as summarised in this question
https://stackoverflow.com/questions/55993192/inconsistent-behaviour-from-json-normalize-with-deeply-nested-json-data
Is this the expected behaviour ?
The text was updated successfully, but these errors were encountered: