File tree Expand file tree Collapse file tree 2 files changed +7
-6
lines changed Expand file tree Collapse file tree 2 files changed +7
-6
lines changed Original file line number Diff line number Diff line change @@ -114,7 +114,6 @@ def is_bool_indexer(key: Any) -> bool:
114
114
check_array_indexer : Check that `key` is a valid array to index,
115
115
and convert to an ndarray.
116
116
"""
117
- na_msg = "cannot mask with array containing NA / NaN values"
118
117
if isinstance (key , (ABCSeries , np .ndarray , ABCIndex )) or (
119
118
is_array_like (key ) and is_extension_array_dtype (key .dtype )
120
119
):
@@ -127,11 +126,6 @@ def is_bool_indexer(key: Any) -> bool:
127
126
return False
128
127
return True
129
128
elif is_bool_dtype (key .dtype ):
130
- # an ndarray with bool-dtype by definition has no missing values.
131
- # So we only need to check for NAs in ExtensionArrays
132
- if is_extension_array_dtype (key .dtype ):
133
- if np .any (key .isna ()):
134
- raise ValueError (na_msg )
135
129
return True
136
130
elif isinstance (key , list ):
137
131
try :
Original file line number Diff line number Diff line change 8
8
from pandas .util ._decorators import Appender
9
9
10
10
from pandas .core .dtypes .common import (
11
+ is_bool_dtype ,
12
+ is_extension_array_dtype ,
11
13
is_float ,
12
14
is_integer ,
13
15
is_iterator ,
@@ -2229,6 +2231,11 @@ def check_bool_indexer(index: Index, key) -> np.ndarray:
2229
2231
"the indexed object do not match)."
2230
2232
)
2231
2233
result = result .astype (bool )._values
2234
+ elif is_extension_array_dtype (key ) and is_bool_dtype (key ):
2235
+ mask = isna (key )
2236
+ if mask .any ():
2237
+ result [mask ] = False
2238
+ result = np .asarray (result , dtype = bool )
2232
2239
else :
2233
2240
# key might be sparse / object-dtype bool, check_array_indexer needs bool array
2234
2241
result = np .asarray (result , dtype = bool )
You can’t perform that action at this time.
0 commit comments