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 2828
2929from pandas ._libs import lib
3030from pandas ._libs .lib import is_range_indexer
31+ from pandas ._libs .missing import NA
3132from pandas ._libs .tslibs import (
3233 Period ,
3334 Timestamp ,
@@ -10099,6 +10100,21 @@ def mask(
1009910100 if not hasattr (cond , "__invert__" ):
1010010101 cond = np .array (cond )
1010110102
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+
1010210118 return self ._where (
1010310119 ~ cond ,
1010410120 other = other ,
You can’t perform that action at this time.
0 commit comments