-
-
Notifications
You must be signed in to change notification settings - Fork 18.4k
BUG: Fixed encoding of pd.NA with to_json #31748
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 all commits
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 |
---|---|---|
|
@@ -1671,3 +1671,13 @@ def test_to_s3(self, s3_resource): | |
assert target_file in ( | ||
obj.key for obj in s3_resource.Bucket("pandas-test").objects.all() | ||
) | ||
|
||
def test_json_pandas_na(self): | ||
# GH 31615 | ||
result = pd.DataFrame([[pd.NA]]).to_json() | ||
assert result == '{"0":{"0":null}}' | ||
|
||
def test_json_pandas_nulls(self, nulls_fixture): | ||
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. @simonjayhawkins do you know of an easy way to add 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. since we already have two nulls_fixtures (nulls_fixture and unique_nulls_fixture), I think adding another could be the simplest way for now. I think, in general, simpler to skip than to add a extra parameter (although I've not kept up with the latest pytest releases). There is not a huge number of tests using the nulls_fixture and maybe tests that do should also test for pandas.NA, either now of in the future. So an alternative could be to add pd.NA to the existing nulls fixture and either skip of xfail. |
||
# GH 31615 | ||
result = pd.DataFrame([[nulls_fixture]]).to_json() | ||
assert result == '{"0":{"0":null}}' |
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.
Thanks @ArtificialQualia
This should be
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.
@MarcoGorelli I've updated that to the correct format.
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.
The original was actually fine, to be consistent with the v1.0.1 file
(sorry for the conflicting comments)
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.
My mistake, sorry, I'd taken that from v1.1.0 where we go back to
, will be more careful in the future
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.
@MarcoGorelli no problem! It's also inconsistent between the different files .. (for the bug fix releases, the list of bugs is much smaller, so less worth it to make subsections. At least, that is what we just did for the v1.0.1 file)
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.
Reverted to original format