

def __getitem__(self, key):
    "\n        Override numpy.ndarray's __getitem__ method to work as desired.\n\n        This function adds lists and Series as valid boolean indexers\n        (ndarrays only supports ndarray with dtype=bool).\n\n        If resulting ndim != 1, plain ndarray is returned instead of\n        corresponding `Index` subclass.\n\n        "
    getitem = self._data.__getitem__
    promote = self._shallow_copy
    if lib.isscalar(key):
        return getitem(key)
    if isinstance(key, slice):
        return promote(getitem(key))
    if is_bool_indexer(key):
        key = np.asarray(key)
    key = _values_from_object(key)
    result = getitem(key)
    if (not lib.isscalar(result)):
        return promote(result)
    else:
        return result

dataset/ETHPy150Open pydata/pandas/pandas/indexes/base.py Index.__getitem__/original