From 04176646b65dba4efcdf6df2f2029905408a9fc7 Mon Sep 17 00:00:00 2001 From: gouravkr Date: Mon, 21 Feb 2022 23:07:43 +0530 Subject: [PATCH] improved slicer class --- fincal/core.py | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/fincal/core.py b/fincal/core.py index d8866a0..34433ea 100644 --- a/fincal/core.py +++ b/fincal/core.py @@ -115,16 +115,17 @@ def _parse_date(date: str, date_format: str = None): class _IndexSlicer: + """Class to create a slice using iloc in TimeSeriesCore""" + def __init__(self, parent_obj): self.parent = parent_obj def __getitem__(self, n): - all_keys = list(self.parent.time_series) if isinstance(n, int): - keys = [all_keys[n]] + keys = [self.parent.dates[n]] else: - keys = all_keys[n] - item = [(key, self.parent.time_series[key]) for key in keys] + keys = self.parent.dates[n] + item = [(key, self.parent.data[key]) for key in keys] if len(item) == 1: return item[0]