From 45fdb9aeafae38c2701d254f6ac67748025284f6 Mon Sep 17 00:00:00 2001 From: yanglinlee Date: Tue, 30 Jul 2019 16:09:31 -0400 Subject: [PATCH] Add regression test for nested meta path in json_normalize --- pandas/tests/io/json/test_normalize.py | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/pandas/tests/io/json/test_normalize.py b/pandas/tests/io/json/test_normalize.py index 4a32f3809c82b..8d93fbcc063f4 100644 --- a/pandas/tests/io/json/test_normalize.py +++ b/pandas/tests/io/json/test_normalize.py @@ -284,6 +284,26 @@ def test_shallow_nested(self): expected = DataFrame(ex_data, columns=result.columns) tm.assert_frame_equal(result, expected) + def test_nested_meta_path_with_nested_record_path(self, state_data): + # GH 27220 + result = json_normalize( + data=state_data, + record_path=["counties"], + meta=["state", "shortname", ["info", "governor"]], + errors="ignore", + ) + + ex_data = { + "name": ["Dade", "Broward", "Palm Beach", "Summit", "Cuyahoga"], + "population": [12345, 40000, 60000, 1234, 1337], + "state": ["Florida"] * 3 + ["Ohio"] * 2, + "shortname": ["FL"] * 3 + ["OH"] * 2, + "info.governor": ["Rick Scott"] * 3 + ["John Kasich"] * 2, + } + + expected = DataFrame(ex_data) + tm.assert_frame_equal(result, expected) + def test_meta_name_conflict(self): data = [ {