All transform tests are now passing
This commit is contained in:
parent
3e5875b873
commit
a4ecd38b97
@ -378,25 +378,25 @@ class TestTransform:
|
||||
assert isinstance(tst, TimeSeries)
|
||||
assert len(tst) == 157
|
||||
assert "2017-01-30" in tst
|
||||
assert tst.iloc[4] == (datetime.datetime(2017, 1, 30), 1021.19)
|
||||
assert tst.iloc[4] == (datetime.datetime(2017, 1, 30), 1020.082)
|
||||
|
||||
def test_daily_to_monthly(self, create_test_data):
|
||||
ts_data = create_test_data(AllFrequencies.D, num=782, skip_weekends=False)
|
||||
ts = TimeSeries(ts_data, "D")
|
||||
tst = ts.transform("M", "mean")
|
||||
assert isinstance(tst, TimeSeries)
|
||||
assert len(tst) == 26
|
||||
assert len(tst) == 27
|
||||
assert "2018-01-01" in tst
|
||||
assert round(tst.iloc[12][1], 2) == 1146.1
|
||||
assert round(tst.iloc[12][1], 2) == 1146.91
|
||||
|
||||
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 len(tst) == 4
|
||||
assert "2019-01-02" in tst
|
||||
assert tst.iloc[2] == (datetime.datetime(2019, 1, 2), 1238.5195)
|
||||
assert tst.iloc[2] == (datetime.datetime(2019, 1, 2), 1157.2835632183908)
|
||||
|
||||
def test_weekly_to_monthly(self, create_test_data):
|
||||
ts_data = create_test_data(AllFrequencies.W, num=261)
|
||||
@ -404,22 +404,22 @@ class TestTransform:
|
||||
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)
|
||||
assert tst.iloc[1] == (datetime.datetime(2017, 2, 1), 1008.405)
|
||||
|
||||
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 len(tst) == 21
|
||||
assert "2018-01-01" in tst
|
||||
assert round(tst.iloc[4][1], 2) == 1054.72
|
||||
assert round(tst.iloc[4][1], 2) == 1032.01
|
||||
|
||||
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
|
||||
assert round(tst.iloc[2][1], 2) == 1053.70
|
||||
with pytest.raises(ValueError):
|
||||
ts.transform("D", "mean")
|
||||
|
||||
@ -427,9 +427,9 @@ class TestTransform:
|
||||
ts_data = create_test_data(AllFrequencies.M, num=36)
|
||||
ts = TimeSeries(ts_data, "M")
|
||||
tst = ts.transform("Q", "mean")
|
||||
assert len(tst) == 12
|
||||
assert len(tst) == 13
|
||||
assert "2018-10-01" in tst
|
||||
assert tst.iloc[7] == (datetime.datetime(2018, 10, 1), 1021.19)
|
||||
assert tst.iloc[7] == (datetime.datetime(2018, 10, 1), 1022.6466666666666)
|
||||
with pytest.raises(ValueError):
|
||||
ts.transform("M", "sum")
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user