tests fro transform method

This commit is contained in:
Gourav Kumar 2022-05-24 21:11:46 +05:30
parent 0a113fdd8a
commit 38fb9ca7d0

View File

@ -354,6 +354,40 @@ class TestReadCsv:
pass pass
class TestTransform:
def test_daily_to_yearly(self, create_test_data):
ts_data = create_test_data(AllFrequencies.D, num=782, skip_weekends=True)
ts = TimeSeries(ts_data, "D")
tst = ts.transform("Y", "mean")
assert isinstance(tst, TimeSeries)
assert len(tst) == 3
assert "2019-01-02" in tst
assert tst.iloc[2] == (datetime.datetime(2019, 1, 2), 1238.5195)
def test_weekly_to_monthly(self, create_test_data):
ts_data = create_test_data(AllFrequencies.W, num=261)
ts = TimeSeries(ts_data, "W")
tst = ts.transform("M", "mean")
assert isinstance(tst, TimeSeries)
assert "2017-01-01" in tst
assert tst.iloc[0] == (datetime.datetime(2017, 1, 1), 1007.33)
def test_weekly_to_qty(self, create_test_data):
ts_data = create_test_data(AllFrequencies.W, num=261)
ts = TimeSeries(ts_data, "W")
tst = ts.transform("Q", "mean")
assert len(tst) == 20
assert "2018-01-01" in tst
assert round(tst.iloc[4][1], 2) == 1054.72
def test_weekly_to_yearly(self, create_test_data):
ts_data = create_test_data(AllFrequencies.W, num=261)
ts = TimeSeries(ts_data, "W")
tst = ts.transform("Y", "mean")
assert "2019-01-01" in tst
assert round(tst.iloc[2][1], 2) == 1054.50
class TestReturnsAgain: class TestReturnsAgain:
data = [ data = [
("2020-01-01", 10), ("2020-01-01", 10),