Skip to content

PERF: Categorical getitem perf #30747

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 5 additions & 2 deletions pandas/core/arrays/categorical.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@
)
from pandas.core.dtypes.dtypes import CategoricalDtype
from pandas.core.dtypes.generic import ABCIndexClass, ABCSeries
from pandas.core.dtypes.inference import is_hashable
from pandas.core.dtypes.inference import is_array_like, is_hashable
from pandas.core.dtypes.missing import isna, notna

from pandas.core import ops
Expand Down Expand Up @@ -1998,7 +1998,10 @@ def __getitem__(self, key):
else:
return self.categories[i]

elif com.is_bool_indexer(key):
if is_list_like(key) and not is_array_like(key):
key = np.asarray(key)

if com.is_bool_indexer(key):
key = check_bool_array_indexer(self, key)

return self._constructor(
Expand Down