improved slicer class
This commit is contained in:
parent
03283f7ed4
commit
04176646b6
@ -115,16 +115,17 @@ def _parse_date(date: str, date_format: str = None):
|
|||||||
|
|
||||||
|
|
||||||
class _IndexSlicer:
|
class _IndexSlicer:
|
||||||
|
"""Class to create a slice using iloc in TimeSeriesCore"""
|
||||||
|
|
||||||
def __init__(self, parent_obj):
|
def __init__(self, parent_obj):
|
||||||
self.parent = parent_obj
|
self.parent = parent_obj
|
||||||
|
|
||||||
def __getitem__(self, n):
|
def __getitem__(self, n):
|
||||||
all_keys = list(self.parent.time_series)
|
|
||||||
if isinstance(n, int):
|
if isinstance(n, int):
|
||||||
keys = [all_keys[n]]
|
keys = [self.parent.dates[n]]
|
||||||
else:
|
else:
|
||||||
keys = all_keys[n]
|
keys = self.parent.dates[n]
|
||||||
item = [(key, self.parent.time_series[key]) for key in keys]
|
item = [(key, self.parent.data[key]) for key in keys]
|
||||||
if len(item) == 1:
|
if len(item) == 1:
|
||||||
return item[0]
|
return item[0]
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user