Skip to content

Add regression test for nested meta path in json_normalize #34090

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 1 commit into from
May 9, 2020
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
20 changes: 20 additions & 0 deletions pandas/tests/io/json/test_normalize.py
Original file line number Diff line number Diff line change
Expand Up @@ -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 = [
{
Expand Down