Skip to content

Commit caee535

Browse files
gfyoungMateusz Górski
authored and
Mateusz Górski
committed
TST: Add test for nested JSON normalization (pandas-dev#29225)
1 parent eaeb9f3 commit caee535

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

pandas/tests/io/json/test_normalize.py

+8
Original file line numberDiff line numberDiff line change
@@ -457,6 +457,14 @@ def test_max_level_with_records_path(self, max_level, expected):
457457
expected_df = DataFrame(data=expected, columns=result.columns.values)
458458
tm.assert_equal(expected_df, result)
459459

460+
def test_nested_flattening_consistent(self):
461+
# see gh-21537
462+
df1 = json_normalize([{"A": {"B": 1}}])
463+
df2 = json_normalize({"dummy": [{"A": {"B": 1}}]}, "dummy")
464+
465+
# They should be the same.
466+
tm.assert_frame_equal(df1, df2)
467+
460468

461469
class TestNestedToRecord:
462470
def test_flat_stays_flat(self):

0 commit comments

Comments
 (0)