From bd1ddbecfdd848b91fffe42e136cfd91b1548048 Mon Sep 17 00:00:00 2001 From: Iqrar Agalosi Nureyza Date: Sat, 29 Feb 2020 12:33:12 +0700 Subject: [PATCH 1/3] fixed PR07 error in pandas.core.groupby.DataFrameGroupBy.shift --- pandas/core/groupby/groupby.py | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/pandas/core/groupby/groupby.py b/pandas/core/groupby/groupby.py index 48c00140461b5..d0c63c5edbbb7 100644 --- a/pandas/core/groupby/groupby.py +++ b/pandas/core/groupby/groupby.py @@ -2317,6 +2317,9 @@ def shift(self, periods=1, freq=None, axis=0, fill_value=None): """ Shift each group by periods observations. + When freq is not passed, shift the index without realigning the data. + If freq is passed, the index will be increased using the periods and the freq. + Parameters ---------- periods : int, default 1 @@ -2324,7 +2327,13 @@ def shift(self, periods=1, freq=None, axis=0, fill_value=None): freq : str, optional Frequency string. axis : axis to shift, default 0 + Shift direction. fill_value : optional + The scalar value to use for newly introduced missing values. + The default depends on the dtype of *self*. + For numeric data, `np.nan` is used. + For datetime, timedelta, or period data, etc. **NaT** is used. + For extension dtypes, `self.dtype.na_value` is used. .. versionadded:: 0.24.0 @@ -2332,6 +2341,14 @@ def shift(self, periods=1, freq=None, axis=0, fill_value=None): ------- Series or DataFrame Object shifted within each group. + + See Also + -------- + Index.shift : Shift values of Index. + DatetimeIndex.resample : Shift values of DatetimeIndex. + PeriodIndex.shift : Shift values of PeriodIndex. + tshift : Shift the time index, using the index’s frequency + if available. """ if freq is not None or axis != 0 or not isna(fill_value): return self.apply(lambda x: x.shift(periods, freq, axis, fill_value)) From 515ce8d1a8af0dc1893088a8cfa910b1fa3926b1 Mon Sep 17 00:00:00 2001 From: Iqrar Agalosi Nureyza Date: Sat, 29 Feb 2020 12:39:28 +0700 Subject: [PATCH 2/3] fixed PR07 error in pandas.core.groupby.DataFrameGroupBy.shift --- pandas/core/groupby/groupby.py | 1 - 1 file changed, 1 deletion(-) diff --git a/pandas/core/groupby/groupby.py b/pandas/core/groupby/groupby.py index d0c63c5edbbb7..b7d76811b3542 100644 --- a/pandas/core/groupby/groupby.py +++ b/pandas/core/groupby/groupby.py @@ -2312,7 +2312,6 @@ def _get_cythonized_result( return self._wrap_transformed_output(output) @Substitution(name="groupby") - @Appender(_common_see_also) def shift(self, periods=1, freq=None, axis=0, fill_value=None): """ Shift each group by periods observations. From 5a7b9476e91fb2efae68b7aae7e056b8a690d671 Mon Sep 17 00:00:00 2001 From: Iqrar Agalosi Nureyza Date: Sun, 1 Mar 2020 09:11:30 +0700 Subject: [PATCH 3/3] removed unnecessary lines --- pandas/core/groupby/groupby.py | 7 ------- 1 file changed, 7 deletions(-) diff --git a/pandas/core/groupby/groupby.py b/pandas/core/groupby/groupby.py index b7d76811b3542..6362f11a3e032 100644 --- a/pandas/core/groupby/groupby.py +++ b/pandas/core/groupby/groupby.py @@ -2316,7 +2316,6 @@ def shift(self, periods=1, freq=None, axis=0, fill_value=None): """ Shift each group by periods observations. - When freq is not passed, shift the index without realigning the data. If freq is passed, the index will be increased using the periods and the freq. Parameters @@ -2329,10 +2328,6 @@ def shift(self, periods=1, freq=None, axis=0, fill_value=None): Shift direction. fill_value : optional The scalar value to use for newly introduced missing values. - The default depends on the dtype of *self*. - For numeric data, `np.nan` is used. - For datetime, timedelta, or period data, etc. **NaT** is used. - For extension dtypes, `self.dtype.na_value` is used. .. versionadded:: 0.24.0 @@ -2344,8 +2339,6 @@ def shift(self, periods=1, freq=None, axis=0, fill_value=None): See Also -------- Index.shift : Shift values of Index. - DatetimeIndex.resample : Shift values of DatetimeIndex. - PeriodIndex.shift : Shift values of PeriodIndex. tshift : Shift the time index, using the index’s frequency if available. """