File tree 2 files changed +6
-3
lines changed
2 files changed +6
-3
lines changed Original file line number Diff line number Diff line change @@ -10472,7 +10472,8 @@ def mask(
10472
10472
cond = common .apply_if_callable (cond , self )
10473
10473
10474
10474
# see gh-21891
10475
- if not hasattr (cond , "__invert__" ):
10475
+ if not hasattr (cond , "shape" ):
10476
+ # not testing __invert__, since `~True` is `-2`.
10476
10477
cond = np .array (cond )
10477
10478
10478
10479
return self .where (
Original file line number Diff line number Diff line change @@ -31,9 +31,11 @@ def test_mask():
31
31
rs2 = s2 .mask (cond [:3 ], - s2 )
32
32
tm .assert_series_equal (rs , rs2 )
33
33
34
+ # test scalar
35
+ assert s .mask (True ).isna ().all ()
36
+ tm .assert_series_equal (s .mask (False ), s )
37
+
34
38
msg = "Array conditional must be same shape as self"
35
- with pytest .raises (ValueError , match = msg ):
36
- s .mask (1 )
37
39
with pytest .raises (ValueError , match = msg ):
38
40
s .mask (cond [:3 ].values , - s )
39
41
You can’t perform that action at this time.
0 commit comments