Skip to content

Commit 31c98c1

Browse files
committed
fixup
1 parent 7861647 commit 31c98c1

File tree

6 files changed

+34
-15
lines changed

6 files changed

+34
-15
lines changed

pandas/core/frame.py

+15
Original file line numberDiff line numberDiff line change
@@ -10697,6 +10697,21 @@ def where(
1069710697
):
1069810698
return super().where(cond, other, inplace, axis, level, errors, try_cast)
1069910699

10700+
@deprecate_nonkeyword_arguments(
10701+
version=None, allowed_args=["self", "cond", "other"]
10702+
)
10703+
def mask(
10704+
self,
10705+
cond,
10706+
other=np.nan,
10707+
inplace=False,
10708+
axis=None,
10709+
level=None,
10710+
errors="raise",
10711+
try_cast=lib.no_default,
10712+
):
10713+
return super().mask(cond, other, inplace, axis, level, errors, try_cast)
10714+
1070010715

1070110716
DataFrame._add_numeric_operations()
1070210717

pandas/core/generic.py

+1-5
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,6 @@
6161
InvalidIndexError,
6262
)
6363
from pandas.util._decorators import (
64-
deprecate_nonkeyword_arguments,
6564
doc,
6665
rewrite_axis_style_signature,
6766
)
@@ -9126,9 +9125,6 @@ def where(
91269125
name="mask",
91279126
name_other="where",
91289127
)
9129-
@deprecate_nonkeyword_arguments(
9130-
version=None, allowed_args=["self", "cond", "other"]
9131-
)
91329128
def mask(
91339129
self,
91349130
cond,
@@ -9148,7 +9144,7 @@ def mask(
91489144
"try_cast keyword is deprecated and will be removed in a "
91499145
"future version",
91509146
FutureWarning,
9151-
stacklevel=3,
9147+
stacklevel=4,
91529148
)
91539149

91549150
# see gh-21891

pandas/core/series.py

+15
Original file line numberDiff line numberDiff line change
@@ -5343,6 +5343,21 @@ def where(
53435343
):
53445344
return super().where(cond, other, inplace, axis, level, errors, try_cast)
53455345

5346+
@deprecate_nonkeyword_arguments(
5347+
version=None, allowed_args=["self", "cond", "other"]
5348+
)
5349+
def mask(
5350+
self,
5351+
cond,
5352+
other=np.nan,
5353+
inplace=False,
5354+
axis=None,
5355+
level=None,
5356+
errors="raise",
5357+
try_cast=lib.no_default,
5358+
):
5359+
return super().mask(cond, other, inplace, axis, level, errors, try_cast)
5360+
53465361
# ----------------------------------------------------------------------
53475362
# Add index
53485363
_AXIS_ORDERS = ["index"]

pandas/tests/frame/indexing/test_mask.py

+1-5
Original file line numberDiff line numberDiff line change
@@ -93,18 +93,14 @@ def test_mask_dtype_bool_conversion(self):
9393
def test_mask_pos_args_deprecation(self):
9494
# https://github.com/pandas-dev/pandas/issues/41485
9595
df = DataFrame({"a": range(5)})
96-
9796
expected = DataFrame({"a": [-1, 1, -1, 3, -1]})
9897
cond = df % 2 == 0
99-
10098
msg = (
101-
r"In a future version of pandas all arguments of NDFrame.mask except for "
99+
r"In a future version of pandas all arguments of DataFrame.mask except for "
102100
r"the arguments 'cond' and 'other' will be keyword-only"
103101
)
104-
105102
with tm.assert_produces_warning(FutureWarning, match=msg):
106103
result = df.mask(cond, -1, False)
107-
108104
tm.assert_frame_equal(result, expected)
109105

110106

pandas/tests/series/indexing/test_mask.py

+1-4
Original file line numberDiff line numberDiff line change
@@ -93,13 +93,10 @@ def test_mask_pos_args_deprecation():
9393
s = Series(range(5))
9494
expected = Series([-1, 1, -1, 3, -1])
9595
cond = s % 2 == 0
96-
9796
msg = (
98-
r"In a future version of pandas all arguments of NDFrame.mask except for "
97+
r"In a future version of pandas all arguments of Series.mask except for "
9998
r"the arguments 'cond' and 'other' will be keyword-only"
10099
)
101-
102100
with tm.assert_produces_warning(FutureWarning, match=msg):
103101
result = s.mask(cond, -1, False)
104-
105102
tm.assert_series_equal(result, expected)

pandas/tests/series/indexing/test_where.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -328,7 +328,7 @@ def test_broadcast(size, mask, item, box):
328328
tm.assert_series_equal(result, expected)
329329

330330
s = Series(data)
331-
result = s.mask(selection, other=box(item))
331+
result = s.mask(selection, box(item))
332332
tm.assert_series_equal(result, expected)
333333

334334

0 commit comments

Comments
 (0)