Skip to content

Commit

Permalink
added other to allowed pos args in mask
Browse files Browse the repository at this point in the history
  • Loading branch information
ShreyDixit committed May 24, 2021
1 parent 6e72701 commit f7be5e0
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 14 deletions.
6 changes: 4 additions & 2 deletions pandas/core/generic.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,8 +61,8 @@
InvalidIndexError,
)
from pandas.util._decorators import (
doc,
deprecate_nonkeyword_arguments,
doc,
rewrite_axis_style_signature,
)
from pandas.util._validators import (
Expand Down Expand Up @@ -9232,7 +9232,9 @@ def where(
name="mask",
name_other="where",
)
@deprecate_nonkeyword_arguments(version="2.0", allowed_args=["self", "cond"])
@deprecate_nonkeyword_arguments(
version=None, allowed_args=["self", "cond", "other"]
)
def mask(
self,
cond,
Expand Down
11 changes: 5 additions & 6 deletions pandas/tests/frame/indexing/test_mask.py
Original file line number Diff line number Diff line change
Expand Up @@ -96,12 +96,11 @@ def test_mask_pos_args_deprecation(self):
cond = df > 0
other = DataFrame(np.random.randn(5, 3))

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

expected = df.mask(cond, other=other, inplace=False)
tm.assert_frame_equal(result, expected)


def test_mask_try_cast_deprecated(frame_or_series):
Expand Down
11 changes: 5 additions & 6 deletions pandas/tests/series/indexing/test_mask.py
Original file line number Diff line number Diff line change
Expand Up @@ -93,9 +93,8 @@ def test_mask_pos_args_deprecation():
s = Series(np.random.randn(6))
cond = s > 0

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

expected = s.mask(cond, other=np.nan, inplace=False)
tm.assert_series_equal(result, expected)

0 comments on commit f7be5e0

Please sign in to comment.