本文整理汇总了Python中pandas.tseries.index.Int64Index.slice_locs方法的典型用法代码示例。如果您正苦于以下问题:Python Int64Index.slice_locs方法的具体用法?Python Int64Index.slice_locs怎么用?Python Int64Index.slice_locs使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类pandas.tseries.index.Int64Index
的用法示例。
在下文中一共展示了Int64Index.slice_locs方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: slice_locs
# 需要导入模块: from pandas.tseries.index import Int64Index [as 别名]
# 或者: from pandas.tseries.index.Int64Index import slice_locs [as 别名]
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)
示例2: slice_locs
# 需要导入模块: from pandas.tseries.index import Int64Index [as 别名]
# 或者: from pandas.tseries.index.Int64Index import slice_locs [as 别名]
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)