-
-
Notifications
You must be signed in to change notification settings - Fork 18.4k
TST: Tests for replace method when column contains pd.NA (#47480) #49805
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 7 commits
4bc0e80
5094008
c30bd01
febffcb
6f90ac3
44331b4
542c4d6
6b2dd72
b2ccbee
2d8910c
62b3168
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 |
---|---|---|
|
@@ -88,12 +88,15 @@ def mask_missing(arr: ArrayLike, values_to_mask) -> npt.NDArray[np.bool_]: | |
|
||
# GH 21977 | ||
mask = np.zeros(arr.shape, dtype=bool) | ||
arr_na_mask = ~isna(arr) | ||
for x in nonna: | ||
if is_numeric_v_string_like(arr, x): | ||
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. pls keep this check. it'll avoid some warnings and will be a fastpath 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. I'd prefer if you pre-compute a mask in case we have object dtype before entering the loop.
|
||
# GH#29553 prevent numpy deprecation warnings | ||
pass | ||
else: | ||
new_mask = arr == x | ||
# GH#47480 | ||
new_mask = np.zeros_like(arr, dtype=bool) | ||
new_mask[arr_na_mask] = arr[arr_na_mask] == x | ||
if not isinstance(new_mask, np.ndarray): | ||
# usually BooleanArray | ||
new_mask = new_mask.to_numpy(dtype=bool, na_value=False) | ||
|
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 we avoid doing this when not necessary? I think we only need this with object dtype
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.
@vs-araujo can you do this