def slice_locs(self, start=None, end=None): """ Index.slice_locs, customized to handle partial ISO-8601 string slicing """ if isinstance(start, basestring) or isinstance(end, basestring): try: if start: start_loc = self._get_string_slice(start).start else: start_loc = 0 if end: end_loc = self._get_string_slice(end).stop else: end_loc = len(self) return start_loc, end_loc except KeyError: pass if isinstance(start, datetime) and isinstance(end, datetime): ordinals = self.values t1 = Period(start, freq=self.freq) t2 = Period(end, freq=self.freq) left = ordinals.searchsorted(t1.ordinal, side='left') right = ordinals.searchsorted(t2.ordinal, side='right') return left, right return Int64Index.slice_locs(self, start, end)
def slice_locs(self, start=None, end=None): """ Index.slice_locs, customized to handle partial ISO-8601 string slicing """ if isinstance(start, basestring) or isinstance(end, basestring): try: if start: start_loc = self._get_string_slice(start).start else: start_loc = 0 if end: end_loc = self._get_string_slice(end).stop else: end_loc = len(self) return start_loc, end_loc except KeyError: pass return Int64Index.slice_locs(self, start, end)