Skip to content

Commit f7be5e0

Browse files
committed
added other to allowed pos args in mask
1 parent 6e72701 commit f7be5e0

File tree

3 files changed

+14
-14
lines changed

3 files changed

+14
-14
lines changed

pandas/core/generic.py

+4-2
Original file line numberDiff line numberDiff line change
@@ -61,8 +61,8 @@
6161
InvalidIndexError,
6262
)
6363
from pandas.util._decorators import (
64-
doc,
6564
deprecate_nonkeyword_arguments,
65+
doc,
6666
rewrite_axis_style_signature,
6767
)
6868
from pandas.util._validators import (
@@ -9232,7 +9232,9 @@ def where(
92329232
name="mask",
92339233
name_other="where",
92349234
)
9235-
@deprecate_nonkeyword_arguments(version="2.0", allowed_args=["self", "cond"])
9235+
@deprecate_nonkeyword_arguments(
9236+
version=None, allowed_args=["self", "cond", "other"]
9237+
)
92369238
def mask(
92379239
self,
92389240
cond,

pandas/tests/frame/indexing/test_mask.py

+5-6
Original file line numberDiff line numberDiff line change
@@ -96,12 +96,11 @@ def test_mask_pos_args_deprecation(self):
9696
cond = df > 0
9797
other = DataFrame(np.random.randn(5, 3))
9898

99-
msg = (
100-
r"Starting with Pandas version 2\.0 all arguments of mask except for the "
101-
r"arguments 'self' and 'cond' will be keyword-only"
102-
)
103-
with tm.assert_produces_warning(FutureWarning, match=msg):
104-
tm.assert_frame_equal(df.mask(cond, other), df.mask(cond, other=other))
99+
with tm.assert_produces_warning(FutureWarning):
100+
result = df.mask(cond, other, False)
101+
102+
expected = df.mask(cond, other=other, inplace=False)
103+
tm.assert_frame_equal(result, expected)
105104

106105

107106
def test_mask_try_cast_deprecated(frame_or_series):

pandas/tests/series/indexing/test_mask.py

+5-6
Original file line numberDiff line numberDiff line change
@@ -93,9 +93,8 @@ def test_mask_pos_args_deprecation():
9393
s = Series(np.random.randn(6))
9494
cond = s > 0
9595

96-
msg = (
97-
r"Starting with Pandas version 2\.0 all arguments of mask except for the "
98-
r"arguments 'self' and 'cond' will be keyword-only"
99-
)
100-
with tm.assert_produces_warning(FutureWarning, match=msg):
101-
tm.assert_series_equal(s.mask(cond, np.nan), s.mask(cond, other=np.nan))
96+
with tm.assert_produces_warning(FutureWarning):
97+
result = s.mask(cond, np.nan, False)
98+
99+
expected = s.mask(cond, other=np.nan, inplace=False)
100+
tm.assert_series_equal(result, expected)

0 commit comments

Comments
 (0)