Skip to content

json_normalize - incorrect removing separator from beginning of key  #49861

Closed
@iyonchev

Description

@iyonchev
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

Metadata

Metadata

Assignees

No one assigned

    Labels

    IO JSONread_json, to_json, json_normalize

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions