From 06be27d46c34697a5d98ff87b9a5b38afb74c668 Mon Sep 17 00:00:00 2001 From: Gourav Kumar Date: Mon, 17 Jul 2023 10:22:43 +0530 Subject: [PATCH] Added ensure_coverage parameter to transform function --- pyfacts/pyfacts.py | 3 ++- tests/test_pyfacts.py | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/pyfacts/pyfacts.py b/pyfacts/pyfacts.py index fd41153..103130b 100644 --- a/pyfacts/pyfacts.py +++ b/pyfacts/pyfacts.py @@ -809,6 +809,7 @@ class TimeSeries(TimeSeriesCore): to_frequency: Literal["W", "M", "Q", "H", "Y"], method: Literal["sum", "mean"], eomonth: bool = False, + ensure_coverage: bool = True, anchor_date=Literal["start", "end"], ) -> TimeSeries: """Transform a time series object into a lower frequency object with an aggregation function. @@ -851,7 +852,7 @@ class TimeSeries(TimeSeriesCore): self.start_date, self.end_date, # + relativedelta(days=to_frequency.days), to_frequency.symbol, - ensure_coverage=True, + ensure_coverage=ensure_coverage, eomonth=eomonth, ) # prev_date = dates[0] diff --git a/tests/test_pyfacts.py b/tests/test_pyfacts.py index 2d04b36..bcc6993 100644 --- a/tests/test_pyfacts.py +++ b/tests/test_pyfacts.py @@ -374,7 +374,7 @@ class TestTransform: def test_daily_to_weekly(self, create_test_data): ts_data = create_test_data(AllFrequencies.D, num=782, skip_weekends=True) ts = TimeSeries(ts_data, "D") - tst = ts.transform("W", "mean") + tst = ts.transform("W", "mean", ensure_coverage=False) assert isinstance(tst, TimeSeries) assert len(tst) == 157 assert "2017-01-30" in tst