File tree Expand file tree Collapse file tree 1 file changed +16
-0
lines changed Expand file tree Collapse file tree 1 file changed +16
-0
lines changed Original file line number Diff line number Diff line change 28
28
29
29
from pandas ._libs import lib
30
30
from pandas ._libs .lib import is_range_indexer
31
+ from pandas ._libs .missing import NA
31
32
from pandas ._libs .tslibs import (
32
33
Period ,
33
34
Timestamp ,
@@ -10099,6 +10100,21 @@ def mask(
10099
10100
if not hasattr (cond , "__invert__" ):
10100
10101
cond = np .array (cond )
10101
10102
10103
+ if isinstance (cond , np .ndarray ):
10104
+ if all (
10105
+ np .apply_along_axis (
10106
+ lambda x : x [0 ] is NA
10107
+ or isinstance (x [0 ], (np .bool_ , bool ))
10108
+ or x [0 ] is np .nan ,
10109
+ axis = 1 ,
10110
+ arr = cond .flatten ().reshape (cond .size , 1 ),
10111
+ )
10112
+ ):
10113
+ if not cond .flags .writeable :
10114
+ cond .setflags (write = 1 )
10115
+ cond [isna (cond )] = False
10116
+ cond = cond .astype (bool )
10117
+
10102
10118
return self ._where (
10103
10119
~ cond ,
10104
10120
other = other ,
You can’t perform that action at this time.
0 commit comments