replaced self.time_series with self.data

This commit is contained in:
Gourav Kumar 2022-02-21 22:27:48 +05:30
parent e22f6acc87
commit 3391f04e19

View File

@ -40,7 +40,7 @@ class TimeSeries(TimeSeriesCore):
def info(self): def info(self):
"""Summary info about the TimeSeries object""" """Summary info about the TimeSeries object"""
total_dates = len(self.time_series.keys()) total_dates = len(self.data.keys())
res_string = "First date: {}\nLast date: {}\nNumber of rows: {}" res_string = "First date: {}\nLast date: {}\nNumber of rows: {}"
return res_string.format(self.start_date, self.end_date, total_dates) return res_string.format(self.start_date, self.end_date, total_dates)
@ -66,13 +66,13 @@ class TimeSeries(TimeSeriesCore):
new_ts = dict() new_ts = dict()
for cur_date in dates_to_fill: for cur_date in dates_to_fill:
try: try:
cur_val = self.time_series[cur_date] cur_val = self.data[cur_date]
except KeyError: except KeyError:
pass pass
new_ts.update({cur_date: cur_val}) new_ts.update({cur_date: cur_val})
if inplace: if inplace:
self.time_series = new_ts self.data = new_ts
return None return None
return TimeSeries(new_ts, frequency=self.frequency.symbol) return TimeSeries(new_ts, frequency=self.frequency.symbol)
@ -100,13 +100,13 @@ class TimeSeries(TimeSeriesCore):
bfill_ts = dict() bfill_ts = dict()
for cur_date in reversed(dates_to_fill): for cur_date in reversed(dates_to_fill):
try: try:
cur_val = self.time_series[cur_date] cur_val = self.data[cur_date]
except KeyError: except KeyError:
pass pass
bfill_ts.update({cur_date: cur_val}) bfill_ts.update({cur_date: cur_val})
new_ts = {k: bfill_ts[k] for k in reversed(bfill_ts)} new_ts = {k: bfill_ts[k] for k in reversed(bfill_ts)}
if inplace: if inplace:
self.time_series = new_ts self.data = new_ts
return None return None
return TimeSeries(new_ts, frequency=self.frequency.symbol) return TimeSeries(new_ts, frequency=self.frequency.symbol)
@ -163,7 +163,7 @@ class TimeSeries(TimeSeriesCore):
as_on_delta, prior_delta = _preprocess_match_options(as_on_match, prior_match, closest) as_on_delta, prior_delta = _preprocess_match_options(as_on_match, prior_match, closest)
while True: while True:
current = self.time_series.get(as_on, None) current = self.data.get(as_on, None)
if current is not None: if current is not None:
break break
elif not as_on_delta: elif not as_on_delta:
@ -172,7 +172,7 @@ class TimeSeries(TimeSeriesCore):
prev_date = as_on - relativedelta(years=years) prev_date = as_on - relativedelta(years=years)
while True: while True:
previous = self.time_series.get(prev_date, None) previous = self.data.get(prev_date, None)
if previous is not None: if previous is not None:
break break
elif not prior_delta: elif not prior_delta:
@ -211,7 +211,7 @@ class TimeSeries(TimeSeriesCore):
dates = create_date_series(from_date, to_date, frequency.symbol) dates = create_date_series(from_date, to_date, frequency.symbol)
if frequency == AllFrequencies.D: if frequency == AllFrequencies.D:
dates = [i for i in dates if i in self.time_series] dates = [i for i in dates if i in self.data]
rolling_returns = [] rolling_returns = []
for i in dates: for i in dates: