-
-
Notifications
You must be signed in to change notification settings - Fork 18.5k
BUG: Add fillna at the beginning of _where not to fill NA. #60729 #60772
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
base: main
Are you sure you want to change the base?
Changes from 1 commit
bc9a942
558569f
bbbc720
e2f32cb
6fd8986
d2d5f62
475f2d1
db30b58
55fe420
cb94cf7
71e442e
b6bd3af
8bac997
89bc1b4
f154cf5
eed6121
9ac81f0
7e3fd3a
8c5ffff
5516517
2437ce2
9556aa4
b64b8a7
9574746
c073c0b
4eea08e
bbc5612
0851593
98fb602
915b8a7
7611f59
88b0530
044d0a9
601f6c9
4528a54
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
Co-authored-by: WillAyd <will_ayd@innobi.io>
- Loading branch information
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,10 @@ | ||
import numpy as np | ||
import pytest | ||
|
||
from pandas import Series | ||
from pandas import ( | ||
Int64Dtype, | ||
Series, | ||
) | ||
import pandas._testing as tm | ||
|
||
|
||
|
@@ -71,15 +74,8 @@ def test_mask_inplace(): | |
|
||
def test_mask_na(): | ||
# We should not be filling pd.NA. See GH#60729 | ||
series = Series([None, 1, 2, None, 3, 4, None]) | ||
series = series.convert_dtypes() | ||
cond = series <= 2 | ||
series = Series([None, 1, 2, None, 3, 4, None], dtype=Int64Dtype()) | ||
result = series.mask(series <= 2, -99) | ||
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 also test the case where the condition is an ndarray and a list. 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. Thanks @rhshadrach , add tests for a list and an ndarray. Could you review the code change? |
||
expected = Series([None, 1, 2, None, -99, -99, None], dtype=Int64Dtype()) | ||
|
||
maskres = series.mask(cond, -99) | ||
whereres = series.where(~(cond), -99) | ||
|
||
expected = Series([None, -99, -99, None, 3, 4, None]) | ||
expected = expected.convert_dtypes() | ||
|
||
tm.assert_series_equal(maskres, expected) | ||
tm.assert_series_equal(maskres, whereres) | ||
tm.assert_series_equal(result, expected) |
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.
Can you also add a test for arrow. Can parametrize with e.g.
Uh oh!
There was an error while loading. Please reload this page.
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, just added a test for pyarrow.