Skip to content

TST: Add test for nested JSON normalization #29225

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

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions pandas/tests/io/json/test_normalize.py
Original file line number Diff line number Diff line change
Expand Up @@ -457,6 +457,14 @@ def test_max_level_with_records_path(self, max_level, expected):
expected_df = DataFrame(data=expected, columns=result.columns.values)
tm.assert_equal(expected_df, result)

def test_nested_flattening_consistent(self):
# see gh-21537
df1 = json_normalize([{"A": {"B": 1}}])
df2 = json_normalize({"dummy": [{"A": {"B": 1}}]}, "dummy")

# They should be the same.
tm.assert_frame_equal(df1, df2)


class TestNestedToRecord:
def test_flat_stays_flat(self):
Expand Down