Skip to content

CLN: dont special-case DatetimeArray indexing #36654

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 8 commits into from
Oct 12, 2020
Prev Previous commit
Next Next commit
use parent class _validate_getitem_key
  • Loading branch information
jbrockmendel committed Sep 26, 2020
commit bdea70bd4c9b03ef50e2db51eda00677c85eea3e
18 changes: 1 addition & 17 deletions pandas/core/arrays/datetimelike.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@
from pandas.core.arrays.base import ExtensionOpsMixin
import pandas.core.common as com
from pandas.core.construction import array, extract_array
from pandas.core.indexers import check_array_indexer, check_setitem_lengths
from pandas.core.indexers import check_setitem_lengths
from pandas.core.ops.common import unpack_zerodim_and_defer
from pandas.core.ops.invalid import invalid_comparison, make_invalid_op

Expand Down Expand Up @@ -522,22 +522,6 @@ def __getitem__(self, key):
result._freq = self._get_getitem_freq(key)
return result

def _validate_getitem_key(self, key):
if com.is_bool_indexer(key):
# first convert to boolean, because check_array_indexer doesn't
# allow object dtype
if is_object_dtype(key):
key = np.asarray(key, dtype=bool)

key = check_array_indexer(self, key)
elif isinstance(key, list) and len(key) == 1 and isinstance(key[0], slice):
# see https://github.com/pandas-dev/pandas/issues/31299, need to allow
# this for now (would otherwise raise in check_array_indexer)
pass
else:
key = super()._validate_getitem_key(key)
return key

def _get_getitem_freq(self, key):
"""
Find the `freq` attribute to assign to the result of a __getitem__ lookup.
Expand Down