Skip to content

Commit 2f8cd27

Browse files
add comment to check_bool_indexer
1 parent 9ed8fe9 commit 2f8cd27

File tree

1 file changed

+3
-4
lines changed

1 file changed

+3
-4
lines changed

pandas/core/indexing.py

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@
1515
is_numeric_dtype,
1616
is_scalar,
1717
is_sequence,
18-
is_sparse,
1918
)
2019
from pandas.core.dtypes.concat import concat_compat
2120
from pandas.core.dtypes.generic import ABCDataFrame, ABCMultiIndex, ABCSeries
@@ -2230,9 +2229,9 @@ def check_bool_indexer(index: Index, key) -> np.ndarray:
22302229
)
22312230
result = result.astype(bool)._values
22322231
else:
2233-
if is_sparse(result):
2234-
result = np.asarray(result)
2235-
result = check_array_indexer(index, np.asarray(result, dtype=bool))
2232+
# key might be sparse / object-dtype bool, check_array_indexer needs bool array
2233+
result = np.asarray(result, dtype=bool)
2234+
result = check_array_indexer(index, result)
22362235

22372236
return result
22382237

0 commit comments

Comments
 (0)