-
-
Notifications
You must be signed in to change notification settings - Fork 18.4k
Fix #21356: JSON nested_to_record Silently Drops Top-Level None Values #21363
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
Changes from 2 commits
2dbf9f2
2ac19b5
0de0cd4
832cc56
a1858c2
e64acdf
2fa7818
f3f7eb9
7471f3e
1027a1c
7bc2124
e7f787e
b7bda86
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -238,15 +238,16 @@ def test_non_ascii_key(self): | |
tm.assert_frame_equal(result, expected) | ||
|
||
def test_missing_field(self, author_missing_data): | ||
# GH20030: Checks for robustness of json_normalize - should | ||
# unnest records where only the first record has a None value | ||
# GH20030: Checks for robustness of json_normalize | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @WillAyd Can you verify this comment once again. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Just the GH issue number is sufficient (like you have below) |
||
result = json_normalize(author_missing_data) | ||
ex_data = [ | ||
{'author_name.first': np.nan, | ||
{'info': np.nan, | ||
'author_name.first': np.nan, | ||
'author_name.last_name': np.nan, | ||
'info.created_at': np.nan, | ||
'info.last_updated': np.nan}, | ||
{'author_name.first': 'Jane', | ||
{'info': None, | ||
'author_name.first': 'Jane', | ||
'author_name.last_name': 'Doe', | ||
'info.created_at': '11/08/1993', | ||
'info.last_updated': '26/05/2012'} | ||
|
@@ -351,9 +352,8 @@ def test_json_normalize_errors(self): | |
errors='raise' | ||
) | ||
|
||
def test_nonetype_dropping(self): | ||
# GH20030: Checks that None values are dropped in nested_to_record | ||
# to prevent additional columns of nans when passed to DataFrame | ||
def test_nonetype(self): | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. can you make this test name more informative |
||
# GH21356 | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Here, i just added the issue number. |
||
data = [ | ||
{'info': None, | ||
'author_name': | ||
|
@@ -367,7 +367,8 @@ def test_nonetype_dropping(self): | |
] | ||
result = nested_to_record(data) | ||
expected = [ | ||
{'author_name.first': 'Smith', | ||
{'info': None, | ||
'author_name.first': 'Smith', | ||
'author_name.last_name': 'Appleseed'}, | ||
{'author_name.first': 'Jane', | ||
'author_name.last_name': 'Doe', | ||
|
@@ -395,6 +396,7 @@ def test_nonetype_top_level_bottom_level(self): | |
} | ||
result = nested_to_record(data) | ||
expected = { | ||
'id': None, | ||
'location.country.state.id': None, | ||
'location.country.state.town.info.id': None, | ||
'location.country.state.town.info.region': None, | ||
|
@@ -423,6 +425,7 @@ def test_nonetype_multiple_levels(self): | |
} | ||
result = nested_to_record(data) | ||
expected = { | ||
'id': None, | ||
'location.id': None, | ||
'location.country.id': None, | ||
'location.country.state.id': None, | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Added the bugfix in the whats new note.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Change of plans here - can you add to the "Fixed Regressions" section in v0.23.1 introduced via #21368?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this also needs to mention json_normalize, add double backticks on
None
.finally, as a user this is not really clear on what has changed, can you re-word a bit.