Skip to content

Commit 9eeb171

Browse files
authored
Add regression test for nested meta path in json_normalize (#34090)
1 parent d67d304 commit 9eeb171

File tree

1 file changed

+20
-0
lines changed

1 file changed

+20
-0
lines changed

pandas/tests/io/json/test_normalize.py

+20
Original file line numberDiff line numberDiff line change
@@ -284,6 +284,26 @@ def test_shallow_nested(self):
284284
expected = DataFrame(ex_data, columns=result.columns)
285285
tm.assert_frame_equal(result, expected)
286286

287+
def test_nested_meta_path_with_nested_record_path(self, state_data):
288+
# GH 27220
289+
result = json_normalize(
290+
data=state_data,
291+
record_path=["counties"],
292+
meta=["state", "shortname", ["info", "governor"]],
293+
errors="ignore",
294+
)
295+
296+
ex_data = {
297+
"name": ["Dade", "Broward", "Palm Beach", "Summit", "Cuyahoga"],
298+
"population": [12345, 40000, 60000, 1234, 1337],
299+
"state": ["Florida"] * 3 + ["Ohio"] * 2,
300+
"shortname": ["FL"] * 3 + ["OH"] * 2,
301+
"info.governor": ["Rick Scott"] * 3 + ["John Kasich"] * 2,
302+
}
303+
304+
expected = DataFrame(ex_data)
305+
tm.assert_frame_equal(result, expected)
306+
287307
def test_meta_name_conflict(self):
288308
data = [
289309
{

0 commit comments

Comments
 (0)