Skip to content

BUG: Change the prompt on non list record path errors (PR: #56405) #56802

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
Show file tree
Hide file tree
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
4 changes: 2 additions & 2 deletions pandas/io/json/_normalize.py
Original file line number Diff line number Diff line change
Expand Up @@ -427,8 +427,8 @@ def _pull_records(js: dict[str, Any], spec: list | str) -> list:
result = []
else:
raise TypeError(
f"{js} has non list value {result} for path {spec}. "
"Must be list or null."
f"Path must contain list or null, "
f"but got {type(result).__name__} at {repr(spec)}"
)
return result

Expand Down
4 changes: 2 additions & 2 deletions pandas/tests/io/json/test_normalize.py
Original file line number Diff line number Diff line change
Expand Up @@ -526,8 +526,8 @@ def test_non_list_record_path_errors(self, value):
test_input = {"state": "Texas", "info": parsed_value}
test_path = "info"
msg = (
f"{test_input} has non list value {parsed_value} for path {test_path}. "
"Must be list or null."
f"Path must contain list or null, "
f"but got {type(parsed_value).__name__} at 'info'"
)
with pytest.raises(TypeError, match=msg):
json_normalize([test_input], record_path=[test_path])
Expand Down