Repository: KIT-IAI/pyWATTS

Issue:
RollingGroupBy WeekdayWeekend and WeekdayWeekendAndHoliday do not work for variance, skewness and kurtosis
**Describe the bug**
If RollingGroupBy.WeekdayWeekend or WeekdayWeekendAndHoliday are specified for RollingVariance RollingSkewness or RollingKurtosis, the RollingMean is calculated

**To Reproduce**
Steps to reproduce the behavior:
1. Create a RollingVariance with WeekdayWeekend as groupby arguments.
2. Run the pipeline and look at the result of RollingVariance

**Expected behavior**
The rollingVariance should be calculated. Not the rollingMean

**Additional context**
In the  cases for WeekdayWeekend and WeekdayWeekendAndHoliday of Rolling base, the mean is calculated instead of calling _get_rollng, if _get_rolling is called there the issue should be fixed.


Discussion:

Patch:
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 683a278..a9a2940 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -11,6 +11,8 @@
 ### Deprecated
 
 ### Fixed
+* Missing call of _get_rolling in Rolling Base  ([#76](https://github.com/KIT-IAI/pyWATTS/issues/76))
+
 
 
 ## 0.1.0 - 2021-25-03
diff --git a/pywatts/modules/rolling_base.py b/pywatts/modules/rolling_base.py
index a833ab6..ef383a3 100644
--- a/pywatts/modules/rolling_base.py
+++ b/pywatts/modules/rolling_base.py
@@ -111,16 +111,12 @@ class RollingBase(BaseTransformer, ABC):
         elif self.group_by == RollingGroupBy.WorkdayWeekend:
             mask = df.index.map(
                 lambda element: element.minute + 1440 if element.weekday() >= 5 else element.hour).values
-            rolling = df.groupby(mask).rolling(f"{self.window_size}{self.window_size_unit}", closed=self.closed,
-                                                    on=df.index).mean().reset_index(0).drop("level_0",
-                                                                                            axis=1).sort_index()
+            rolling = self._get_rolling(df.groupby(mask)).reset_index(0).drop("level_0", axis=1).sort_index()
         elif self.group_by == RollingGroupBy.WorkdayWeekendAndHoliday:
             mask = df.index.map(lambda element:
                                 element.minute + 1440 if self.cal.is_holiday(element) or element.weekday() >= 5
                                 else element.hour).values
-            rolling = df.groupby(mask).rolling(f"{self.window_size}{self.window_size_unit}", closed=self.closed,
-                                                    on=df.index).mean().reset_index(0).drop("level_0",
-                                                                                            axis=1).sort_index()
+            rolling = self._get_rolling(df.groupby(mask)).reset_index(0).drop("level_0", axis=1).sort_index()
         else:
             raise WrongParameterException(
                 "GroupBy has to be RollingGroupBy.No, RollingGroupBy.WorkdayWeekend, "


Test patch:
diff --git a/tests/unit/modules/test_rolling_variance.py b/tests/unit/modules/test_rolling_variance.py
index 270f769..5365dc7 100644
--- a/tests/unit/modules/test_rolling_variance.py
+++ b/tests/unit/modules/test_rolling_variance.py
@@ -62,3 +62,23 @@ class TestRollingVariance(unittest.TestCase):
         expected_result = xr.DataArray([0., 0, 0.5, 1., 1., 1., 1.], dims=["time"], coords={'time': time})
 
         xr.testing.assert_equal(result, expected_result)
+
+    def test_transform_groupbyWeekend(self):
+        time = pd.date_range('2002-01-01', freq='24H', periods=7)
+        self.rolling_variance.set_params(group_by=RollingGroupBy.WorkdayWeekend)
+        da = xr.DataArray([2, 3, 4, 5, 6, 7, 8], dims=["time"], coords={'time': time})
+
+        result = self.rolling_variance.transform(da)
+
+        expected_result = xr.DataArray([0., 0, 0.5, 1., 0, 0, 0], dims=["time"], coords={'time': time})
+        xr.testing.assert_equal(result, expected_result)
+
+    def test_transform_groupbyWeekendHoliday(self):
+        time = pd.date_range('2002-01-01', freq='24H', periods=7)
+        self.rolling_variance.set_params(group_by=RollingGroupBy.WorkdayWeekendAndHoliday)
+        da = xr.DataArray([2, 3, 4, 5, 6, 7, 8], dims=["time"], coords={'time': time})
+
+        result = self.rolling_variance.transform(da)
+
+        expected_result = xr.DataArray([0., 0, 0, .5, 0, 0, 0], dims=["time"], coords={'time': time})
+        xr.testing.assert_equal(result, expected_result)