Skip to content

json_normalize - incorrect removing separator from beginning of key #49861

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
iyonchev opened this issue Nov 23, 2022 · 2 comments · Fixed by #49920
Closed

json_normalize - incorrect removing separator from beginning of key #49861

iyonchev opened this issue Nov 23, 2022 · 2 comments · Fixed by #49920
Labels
IO JSON read_json, to_json, json_normalize

Comments

@iyonchev
Copy link

print(pd.__version__)
jsn={'_id':{'a1':10,"l2":{"l3":0}}, "gg":4}
display(pd.json_normalize(jsn,sep='_'))

Actual result:

1.5.2
  gg id_a1 id_l2_l3
4 10 0

Expected result:
the "_" prefix should not be removed from the beginning of the column names.

1.5.2
  gg _id_a1 _id_l2_l3
4 10 0

This issue was introduced with the following change:
https://github.com/pandas-dev/pandas/pull/40035/files

@iyonchev
Copy link
Author

display(pd.json_normalize(jsn,sep='_', max_level=5))
passing max_level value could be used to prevent the execution of the new methods(from the change above) and execute the main one...

@jbrockmendel jbrockmendel added the IO JSON read_json, to_json, json_normalize label Nov 25, 2022
@jbrockmendel
Copy link
Member

Cc @WillAyd

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
IO JSON read_json, to_json, json_normalize
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants