From da47224ebc832fa792c325059269fb77113a0445 Mon Sep 17 00:00:00 2001 From: yhaque Date: Thu, 11 Apr 2019 16:21:03 -0400 Subject: [PATCH 01/25] Added axis to constructor call in count --- pandas/core/window.py | 1 + 1 file changed, 1 insertion(+) diff --git a/pandas/core/window.py b/pandas/core/window.py index 416647831880d..310b355594329 100644 --- a/pandas/core/window.py +++ b/pandas/core/window.py @@ -938,6 +938,7 @@ def count(self): result = b.notna().astype(int) result = self._constructor(result, window=window, min_periods=0, center=self.center, + axis=self.axis, closed=self.closed).sum() results.append(result) From c64c76a30d1bd32b415010a297b5af6e15332445 Mon Sep 17 00:00:00 2001 From: yhaque Date: Thu, 11 Apr 2019 22:47:35 -0400 Subject: [PATCH 02/25] TST: GH26055 added test_count_axis to TestRolling --- pandas/tests/test_window.py | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/pandas/tests/test_window.py b/pandas/tests/test_window.py index 8e2925f52c04d..faf248a305a45 100644 --- a/pandas/tests/test_window.py +++ b/pandas/tests/test_window.py @@ -667,6 +667,18 @@ def test_rolling_axis(self, axis_frame): result = df.rolling(3, axis=axis_frame).sum() tm.assert_frame_equal(result, expected) + def test_count_axis(self): + # see gh-26055 + df = pd.DataFrame({'x':range(5), 'y':range(5)}) + + df_correct_row_count = pd.DataFrame({'x':[1.0, 2.0, 2.0, 2.0, 2.0], 'y': [1.0, 2.0, 2.0, 2.0, 2.0]}) + + assert_equal(df.rolling(2).count(), df_correct_row_count) + assert_equal(df.rolling(2, axis='rows').count(), df_correct_row_count) + + df_correct_column_count = pd.DataFrame({'x':[1.0, 1.0, 1.0, 1.0, 1.0], 'y': [2.0, 2.0, 2.0, 2.0, 2.0]}) + assert_equal(df.rolling(2, axis='columns').count(), df_correct_column_count) + class TestExpanding(Base): From 90c6915d7b88439e763db9cfc045d27c284a47d7 Mon Sep 17 00:00:00 2001 From: yhaque Date: Fri, 12 Apr 2019 17:05:36 -0400 Subject: [PATCH 03/25] TST: fixed asserts and pep8 for test_count_axis() --- pandas/tests/test_window.py | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/pandas/tests/test_window.py b/pandas/tests/test_window.py index faf248a305a45..64b1af87dc626 100644 --- a/pandas/tests/test_window.py +++ b/pandas/tests/test_window.py @@ -669,15 +669,21 @@ def test_rolling_axis(self, axis_frame): def test_count_axis(self): # see gh-26055 - df = pd.DataFrame({'x':range(5), 'y':range(5)}) + df = pd.DataFrame({'x': range(5), 'y': range(5)}) - df_correct_row_count = pd.DataFrame({'x':[1.0, 2.0, 2.0, 2.0, 2.0], 'y': [1.0, 2.0, 2.0, 2.0, 2.0]}) + df_correct_row_count = pd.DataFrame({'x': [1.0, 2.0, 2.0, 2.0, 2.0], + 'y': [1.0, 2.0, 2.0, 2.0, 2.0]}) - assert_equal(df.rolling(2).count(), df_correct_row_count) - assert_equal(df.rolling(2, axis='rows').count(), df_correct_row_count) + # not specifiying axis and making axis=rows should be the same result + tm.assert_frame_equal(df.rolling(2).count(), df_correct_row_count) + tm.assert_frame_equal(df.rolling(2, axis='rows').count(), + df_correct_row_count) - df_correct_column_count = pd.DataFrame({'x':[1.0, 1.0, 1.0, 1.0, 1.0], 'y': [2.0, 2.0, 2.0, 2.0, 2.0]}) - assert_equal(df.rolling(2, axis='columns').count(), df_correct_column_count) + df_correct_column_count = pd.DataFrame({'x': [1.0, 1.0, 1.0, 1.0, 1.0], + 'y': [2.0, 2.0, 2.0, 2.0, 2.0]} + ) + tm.assert_frame_equal(df.rolling(2, axis='columns').count(), + df_correct_column_count) class TestExpanding(Base): From 49065029269234f6858854432cde93990ea961de Mon Sep 17 00:00:00 2001 From: yhaque Date: Sat, 13 Apr 2019 12:25:21 -0400 Subject: [PATCH 04/25] TST: GH26055 rebasing with master --- pandas/tests/test_window.py | 20 +++++++------------- 1 file changed, 7 insertions(+), 13 deletions(-) diff --git a/pandas/tests/test_window.py b/pandas/tests/test_window.py index 64b1af87dc626..f98ace8e281b8 100644 --- a/pandas/tests/test_window.py +++ b/pandas/tests/test_window.py @@ -669,21 +669,15 @@ def test_rolling_axis(self, axis_frame): def test_count_axis(self): # see gh-26055 - df = pd.DataFrame({'x': range(5), 'y': range(5)}) - - df_correct_row_count = pd.DataFrame({'x': [1.0, 2.0, 2.0, 2.0, 2.0], - 'y': [1.0, 2.0, 2.0, 2.0, 2.0]}) + df = DataFrame({'x': range(3), 'y': range(3)}) + df_row = DataFrame({'x': [1.0, 2.0, 2.0], 'y': [1.0, 2.0, 2.0]}) # not specifiying axis and making axis=rows should be the same result - tm.assert_frame_equal(df.rolling(2).count(), df_correct_row_count) - tm.assert_frame_equal(df.rolling(2, axis='rows').count(), - df_correct_row_count) - - df_correct_column_count = pd.DataFrame({'x': [1.0, 1.0, 1.0, 1.0, 1.0], - 'y': [2.0, 2.0, 2.0, 2.0, 2.0]} - ) - tm.assert_frame_equal(df.rolling(2, axis='columns').count(), - df_correct_column_count) + tm.assert_frame_equal(df.rolling(2).count(), df_row) + tm.assert_frame_equal(df.rolling(2, axis='rows').count(), df_row) + + df_col = DataFrame({'x': [1.0, 1.0, 1.0], 'y': [2.0, 2.0, 2.0]}) + tm.assert_frame_equal(df.rolling(2, axis='columns').count(), df_col) class TestExpanding(Base): From c6e12321d8a336ea0def0fd7b579ae854d15a3ae Mon Sep 17 00:00:00 2001 From: yhaque Date: Wed, 17 Apr 2019 20:17:47 -0400 Subject: [PATCH 05/25] TST: GH26055 added whatsnew entry and renamed result and expected variables --- doc/source/whatsnew/v0.25.0.rst | 1 + pandas/tests/test_window.py | 20 ++++++++++++-------- 2 files changed, 13 insertions(+), 8 deletions(-) diff --git a/doc/source/whatsnew/v0.25.0.rst b/doc/source/whatsnew/v0.25.0.rst index c441244b4415d..cc6dd5788540d 100644 --- a/doc/source/whatsnew/v0.25.0.rst +++ b/doc/source/whatsnew/v0.25.0.rst @@ -384,6 +384,7 @@ Groupby/Resample/Rolling - Ensured that result group order is correct when grouping on an ordered ``Categorical`` and specifying ``observed=True`` (:issue:`25871`, :issue:`25167`) - Bug in :meth:`pandas.core.window.Rolling.min` and :meth:`pandas.core.window.Rolling.max` that caused a memory leak (:issue:`25893`) - Bug in :func:`idxmax` and :func:`idxmin` on :meth:`DataFrame.groupby` with datetime column would return incorrect dtype (:issue:`25444`, :issue:`15306`) +- Bug in :meth:`pandas.core.window._Rolling_and_Expanding.count` that did not include axis parameter in constructor call (:issue:`13503`) Reshaping ^^^^^^^^^ diff --git a/pandas/tests/test_window.py b/pandas/tests/test_window.py index f98ace8e281b8..d63eafced65bf 100644 --- a/pandas/tests/test_window.py +++ b/pandas/tests/test_window.py @@ -648,7 +648,7 @@ def test_iter_raises(self, klass): with pytest.raises(NotImplementedError): iter(obj.rolling(2)) - def test_rolling_axis(self, axis_frame): + def test_rolling_axis_sum(self, axis_frame): # see gh-23372. df = DataFrame(np.ones((10, 20))) axis = df._get_axis_number(axis_frame) @@ -667,17 +667,21 @@ def test_rolling_axis(self, axis_frame): result = df.rolling(3, axis=axis_frame).sum() tm.assert_frame_equal(result, expected) - def test_count_axis(self): + def test_rolling_axis_count(self): # see gh-26055 df = DataFrame({'x': range(3), 'y': range(3)}) - df_row = DataFrame({'x': [1.0, 2.0, 2.0], 'y': [1.0, 2.0, 2.0]}) - # not specifiying axis and making axis=rows should be the same result - tm.assert_frame_equal(df.rolling(2).count(), df_row) - tm.assert_frame_equal(df.rolling(2, axis='rows').count(), df_row) + result = df.rolling(2).count() + expected = DataFrame({'x': [1.0, 2.0, 2.0], 'y': [1.0, 2.0, 2.0]}) + tm.assert_frame_equal(result, expected) + + # not specifiying axis and making axis=rows are expected to yeild the same result + result = df.rolling(2, axis='rows').count() + tm.assert_frame_equal(result, expected) - df_col = DataFrame({'x': [1.0, 1.0, 1.0], 'y': [2.0, 2.0, 2.0]}) - tm.assert_frame_equal(df.rolling(2, axis='columns').count(), df_col) + result = df.rolling(2, axis='columns').count() + expected = DataFrame({'x': [1.0, 1.0, 1.0], 'y': [2.0, 2.0, 2.0]}) + tm.assert_frame_equal(result, expected) class TestExpanding(Base): From 41ae7fe198e3a224207c7aa3cd0bc021c9304830 Mon Sep 17 00:00:00 2001 From: yhaque Date: Thu, 18 Apr 2019 11:49:11 -0400 Subject: [PATCH 06/25] TST: GH26055 corrected doc errors and test pep8 errors --- doc/source/whatsnew/v0.25.0.rst | 2 +- pandas/tests/test_window.py | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/doc/source/whatsnew/v0.25.0.rst b/doc/source/whatsnew/v0.25.0.rst index cc6dd5788540d..3a75f3381e6fc 100644 --- a/doc/source/whatsnew/v0.25.0.rst +++ b/doc/source/whatsnew/v0.25.0.rst @@ -384,7 +384,7 @@ Groupby/Resample/Rolling - Ensured that result group order is correct when grouping on an ordered ``Categorical`` and specifying ``observed=True`` (:issue:`25871`, :issue:`25167`) - Bug in :meth:`pandas.core.window.Rolling.min` and :meth:`pandas.core.window.Rolling.max` that caused a memory leak (:issue:`25893`) - Bug in :func:`idxmax` and :func:`idxmin` on :meth:`DataFrame.groupby` with datetime column would return incorrect dtype (:issue:`25444`, :issue:`15306`) -- Bug in :meth:`pandas.core.window._Rolling_and_Expanding.count` that did not include axis parameter in constructor call (:issue:`13503`) +- Bug in :meth:`pandas.core.window._Rolling_and_Expanding.count` that did not include axis parameter in constructor call (:issue:`13503`) Reshaping ^^^^^^^^^ diff --git a/pandas/tests/test_window.py b/pandas/tests/test_window.py index d63eafced65bf..4596ee99f0b39 100644 --- a/pandas/tests/test_window.py +++ b/pandas/tests/test_window.py @@ -675,7 +675,8 @@ def test_rolling_axis_count(self): expected = DataFrame({'x': [1.0, 2.0, 2.0], 'y': [1.0, 2.0, 2.0]}) tm.assert_frame_equal(result, expected) - # not specifiying axis and making axis=rows are expected to yeild the same result + # not specifiying axis and making axis=rows + # are expected to yeild the same result result = df.rolling(2, axis='rows').count() tm.assert_frame_equal(result, expected) From 12065b6a93a639d1df8e92feb8307d22868fca3d Mon Sep 17 00:00:00 2001 From: yhaque Date: Fri, 19 Apr 2019 16:13:57 -0400 Subject: [PATCH 07/25] TST: GH26055 fixed comment typo --- pandas/tests/test_window.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pandas/tests/test_window.py b/pandas/tests/test_window.py index 4596ee99f0b39..af4167be25665 100644 --- a/pandas/tests/test_window.py +++ b/pandas/tests/test_window.py @@ -676,7 +676,7 @@ def test_rolling_axis_count(self): tm.assert_frame_equal(result, expected) # not specifiying axis and making axis=rows - # are expected to yeild the same result + # are expected to yield the same result result = df.rolling(2, axis='rows').count() tm.assert_frame_equal(result, expected) From 80c8648704679db56beab90567a8cfe5114e1e71 Mon Sep 17 00:00:00 2001 From: yhaque Date: Fri, 19 Apr 2019 16:50:36 -0400 Subject: [PATCH 08/25] TST: GH26055 fixed docs description and added axis_frame to test --- doc/source/whatsnew/v0.25.0.rst | 3 ++- pandas/tests/test_window.py | 18 ++++++++---------- 2 files changed, 10 insertions(+), 11 deletions(-) diff --git a/doc/source/whatsnew/v0.25.0.rst b/doc/source/whatsnew/v0.25.0.rst index 3a75f3381e6fc..8af6acd2cf51a 100644 --- a/doc/source/whatsnew/v0.25.0.rst +++ b/doc/source/whatsnew/v0.25.0.rst @@ -384,7 +384,8 @@ Groupby/Resample/Rolling - Ensured that result group order is correct when grouping on an ordered ``Categorical`` and specifying ``observed=True`` (:issue:`25871`, :issue:`25167`) - Bug in :meth:`pandas.core.window.Rolling.min` and :meth:`pandas.core.window.Rolling.max` that caused a memory leak (:issue:`25893`) - Bug in :func:`idxmax` and :func:`idxmin` on :meth:`DataFrame.groupby` with datetime column would return incorrect dtype (:issue:`25444`, :issue:`15306`) -- Bug in :meth:`pandas.core.window._Rolling_and_Expanding.count` that did not include axis parameter in constructor call (:issue:`13503`) +- Bug in :meth:`pandas.core.window.Rolling.count` was previously ignoring the axis keyword (:issue:`13503`) +- Bug in :meth:`pandas.core.window.Expanding.count` was previously ignoring the axis keyword (:issue:`13503`) Reshaping ^^^^^^^^^ diff --git a/pandas/tests/test_window.py b/pandas/tests/test_window.py index af4167be25665..a31832af58a8c 100644 --- a/pandas/tests/test_window.py +++ b/pandas/tests/test_window.py @@ -667,21 +667,19 @@ def test_rolling_axis_sum(self, axis_frame): result = df.rolling(3, axis=axis_frame).sum() tm.assert_frame_equal(result, expected) - def test_rolling_axis_count(self): + def test_rolling_axis_count(self, axis_frame): # see gh-26055 df = DataFrame({'x': range(3), 'y': range(3)}) - result = df.rolling(2).count() - expected = DataFrame({'x': [1.0, 2.0, 2.0], 'y': [1.0, 2.0, 2.0]}) - tm.assert_frame_equal(result, expected) + axis = df._get_axis_number(axis_frame) - # not specifiying axis and making axis=rows - # are expected to yield the same result - result = df.rolling(2, axis='rows').count() - tm.assert_frame_equal(result, expected) + if axis == 0: + expected = DataFrame({'x': [1.0, 2.0, 2.0], 'y': [1.0, 2.0, 2.0]}) + else: + # axis == 1 + expected = DataFrame({'x': [1.0, 1.0, 1.0], 'y': [2.0, 2.0, 2.0]}) - result = df.rolling(2, axis='columns').count() - expected = DataFrame({'x': [1.0, 1.0, 1.0], 'y': [2.0, 2.0, 2.0]}) + result = df.rolling(2, axis=axis_frame).count() tm.assert_frame_equal(result, expected) From 0f94d87571dedb14d3f5aacbab479b295fd88da8 Mon Sep 17 00:00:00 2001 From: yhaque Date: Sat, 20 Apr 2019 18:30:24 -0400 Subject: [PATCH 09/25] Combined description in doc and modified if statement in test to correct the axis check --- doc/source/whatsnew/v0.25.0.rst | 3 +-- pandas/tests/test_window.py | 2 +- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/doc/source/whatsnew/v0.25.0.rst b/doc/source/whatsnew/v0.25.0.rst index 8af6acd2cf51a..3869bf1699b4d 100644 --- a/doc/source/whatsnew/v0.25.0.rst +++ b/doc/source/whatsnew/v0.25.0.rst @@ -384,8 +384,7 @@ Groupby/Resample/Rolling - Ensured that result group order is correct when grouping on an ordered ``Categorical`` and specifying ``observed=True`` (:issue:`25871`, :issue:`25167`) - Bug in :meth:`pandas.core.window.Rolling.min` and :meth:`pandas.core.window.Rolling.max` that caused a memory leak (:issue:`25893`) - Bug in :func:`idxmax` and :func:`idxmin` on :meth:`DataFrame.groupby` with datetime column would return incorrect dtype (:issue:`25444`, :issue:`15306`) -- Bug in :meth:`pandas.core.window.Rolling.count` was previously ignoring the axis keyword (:issue:`13503`) -- Bug in :meth:`pandas.core.window.Expanding.count` was previously ignoring the axis keyword (:issue:`13503`) +- Bug in :meth:`pandas.core.window.Rolling.count` and `pandas.core.window.Expanding.count` was previously ignoring the axis keyword (:issue:`13503`) Reshaping ^^^^^^^^^ diff --git a/pandas/tests/test_window.py b/pandas/tests/test_window.py index a31832af58a8c..7b5a17c17dda8 100644 --- a/pandas/tests/test_window.py +++ b/pandas/tests/test_window.py @@ -673,7 +673,7 @@ def test_rolling_axis_count(self, axis_frame): axis = df._get_axis_number(axis_frame) - if axis == 0: + if axis in [0, 'index']: expected = DataFrame({'x': [1.0, 2.0, 2.0], 'y': [1.0, 2.0, 2.0]}) else: # axis == 1 From 1c0f4754f45c6f2bdf320ec3cedb9e8a15a7ef3e Mon Sep 17 00:00:00 2001 From: yhaque Date: Sat, 20 Apr 2019 18:55:46 -0400 Subject: [PATCH 10/25] TST: GH26055 Same changes as previous commit, merge did not pass checks, trying rebase --- pandas/tests/test_window.py | 1 - 1 file changed, 1 deletion(-) diff --git a/pandas/tests/test_window.py b/pandas/tests/test_window.py index 7b5a17c17dda8..6f689a803bff4 100644 --- a/pandas/tests/test_window.py +++ b/pandas/tests/test_window.py @@ -676,7 +676,6 @@ def test_rolling_axis_count(self, axis_frame): if axis in [0, 'index']: expected = DataFrame({'x': [1.0, 2.0, 2.0], 'y': [1.0, 2.0, 2.0]}) else: - # axis == 1 expected = DataFrame({'x': [1.0, 1.0, 1.0], 'y': [2.0, 2.0, 2.0]}) result = df.rolling(2, axis=axis_frame).count() From 0317be02129e85635533472f872f9fea09d8d71a Mon Sep 17 00:00:00 2001 From: yhaque Date: Mon, 22 Apr 2019 12:59:35 -0400 Subject: [PATCH 11/25] CLN: GH26055 fixed doc and undid unintentionally added commits --- doc/source/whatsnew/v0.25.0.rst | 2 +- pandas/core/window.py | 1 + pandas/tests/test_window.py | 16 +++++++++++++++- 3 files changed, 17 insertions(+), 2 deletions(-) diff --git a/doc/source/whatsnew/v0.25.0.rst b/doc/source/whatsnew/v0.25.0.rst index c441244b4415d..90f105ba65986 100644 --- a/doc/source/whatsnew/v0.25.0.rst +++ b/doc/source/whatsnew/v0.25.0.rst @@ -383,7 +383,7 @@ Groupby/Resample/Rolling - Ensured that ordering of outputs in ``groupby`` aggregation functions is consistent across all versions of Python (:issue:`25692`) - Ensured that result group order is correct when grouping on an ordered ``Categorical`` and specifying ``observed=True`` (:issue:`25871`, :issue:`25167`) - Bug in :meth:`pandas.core.window.Rolling.min` and :meth:`pandas.core.window.Rolling.max` that caused a memory leak (:issue:`25893`) -- Bug in :func:`idxmax` and :func:`idxmin` on :meth:`DataFrame.groupby` with datetime column would return incorrect dtype (:issue:`25444`, :issue:`15306`) +- Bug in :meth:`pandas.core.window.Rolling.count` and `pandas.core. window.Expanding.count` was previously ignoring the axis keyword (:issue:`13503`) Reshaping ^^^^^^^^^ diff --git a/pandas/core/window.py b/pandas/core/window.py index 416647831880d..b6da9fe2f6db6 100644 --- a/pandas/core/window.py +++ b/pandas/core/window.py @@ -937,6 +937,7 @@ def count(self): for b in blocks: result = b.notna().astype(int) result = self._constructor(result, window=window, min_periods=0, + axis=self.axis, center=self.center, closed=self.closed).sum() results.append(result) diff --git a/pandas/tests/test_window.py b/pandas/tests/test_window.py index 8e2925f52c04d..6f689a803bff4 100644 --- a/pandas/tests/test_window.py +++ b/pandas/tests/test_window.py @@ -648,7 +648,7 @@ def test_iter_raises(self, klass): with pytest.raises(NotImplementedError): iter(obj.rolling(2)) - def test_rolling_axis(self, axis_frame): + def test_rolling_axis_sum(self, axis_frame): # see gh-23372. df = DataFrame(np.ones((10, 20))) axis = df._get_axis_number(axis_frame) @@ -667,6 +667,20 @@ def test_rolling_axis(self, axis_frame): result = df.rolling(3, axis=axis_frame).sum() tm.assert_frame_equal(result, expected) + def test_rolling_axis_count(self, axis_frame): + # see gh-26055 + df = DataFrame({'x': range(3), 'y': range(3)}) + + axis = df._get_axis_number(axis_frame) + + if axis in [0, 'index']: + expected = DataFrame({'x': [1.0, 2.0, 2.0], 'y': [1.0, 2.0, 2.0]}) + else: + expected = DataFrame({'x': [1.0, 1.0, 1.0], 'y': [2.0, 2.0, 2.0]}) + + result = df.rolling(2, axis=axis_frame).count() + tm.assert_frame_equal(result, expected) + class TestExpanding(Base): From 852ed4abf8c364aa2acd74ff429a7f8bcbb3a443 Mon Sep 17 00:00:00 2001 From: yhaque Date: Mon, 22 Apr 2019 13:07:44 -0400 Subject: [PATCH 12/25] DOC: GH26055 removed extra doc line --- doc/source/whatsnew/v0.25.0.rst | 1 - 1 file changed, 1 deletion(-) diff --git a/doc/source/whatsnew/v0.25.0.rst b/doc/source/whatsnew/v0.25.0.rst index 90f105ba65986..b2c298936f30f 100644 --- a/doc/source/whatsnew/v0.25.0.rst +++ b/doc/source/whatsnew/v0.25.0.rst @@ -401,7 +401,6 @@ Sparse - Significant speedup in `SparseArray` initialization that benefits most operations, fixing performance regression introduced in v0.20.0 (:issue:`24985`) - Bug in :class:`SparseFrame` constructor where passing ``None`` as the data would cause ``default_fill_value`` to be ignored (:issue:`16807`) -- Other From 0777c54c610a31c3994f8b1b7aa22259d60c0976 Mon Sep 17 00:00:00 2001 From: yhaque Date: Mon, 22 Apr 2019 13:12:56 -0400 Subject: [PATCH 13/25] DOC: GH26055 removed extra doc lines --- doc/source/whatsnew/v0.25.0.rst | 3 --- 1 file changed, 3 deletions(-) diff --git a/doc/source/whatsnew/v0.25.0.rst b/doc/source/whatsnew/v0.25.0.rst index 02f5397947753..c87143a959cf2 100644 --- a/doc/source/whatsnew/v0.25.0.rst +++ b/doc/source/whatsnew/v0.25.0.rst @@ -390,10 +390,7 @@ Groupby/Resample/Rolling - Ensured that ordering of outputs in ``groupby`` aggregation functions is consistent across all versions of Python (:issue:`25692`) - Ensured that result group order is correct when grouping on an ordered ``Categorical`` and specifying ``observed=True`` (:issue:`25871`, :issue:`25167`) - Bug in :meth:`pandas.core.window.Rolling.min` and :meth:`pandas.core.window.Rolling.max` that caused a memory leak (:issue:`25893`) -- Bug in :func:`idxmax` and :func:`idxmin` on :meth:`DataFrame.groupby` with datetime column would return incorrect dtype (:issue:`25444`, :issue:`15306`) - Bug in :meth:`pandas.core.window.Rolling.count` and `pandas.core.window.Expanding.count` was previously ignoring the axis keyword (:issue:`13503`) -- Bug in :meth:`pandas.core.groupby.GroupBy.idxmax` and :meth:`pandas.core.groupby.GroupBy.idxmin` with datetime column would return incorrect dtype (:issue:`25444`, :issue:`15306`) -- Bug in :meth:`pandas.core.groupby.GroupBy.cumsum`, :meth:`pandas.core.groupby.GroupBy.cumprod`, :meth:`pandas.core.groupby.GroupBy.cummin` and :meth:`pandas.core.groupby.GroupBy.cummax` with categorical column having absent categories, would return incorrect result or segfault (:issue:`16771`) Reshaping ^^^^^^^^^ From 6c99ab3f7bd152f4cdbf1493e9c03d95b68c2bf5 Mon Sep 17 00:00:00 2001 From: yhaque Date: Mon, 22 Apr 2019 13:22:18 -0400 Subject: [PATCH 14/25] DOC: GH26055 readded accidentally removed doc lines --- doc/source/whatsnew/v0.25.0.rst | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/doc/source/whatsnew/v0.25.0.rst b/doc/source/whatsnew/v0.25.0.rst index c87143a959cf2..681243e0da34a 100644 --- a/doc/source/whatsnew/v0.25.0.rst +++ b/doc/source/whatsnew/v0.25.0.rst @@ -391,7 +391,9 @@ Groupby/Resample/Rolling - Ensured that result group order is correct when grouping on an ordered ``Categorical`` and specifying ``observed=True`` (:issue:`25871`, :issue:`25167`) - Bug in :meth:`pandas.core.window.Rolling.min` and :meth:`pandas.core.window.Rolling.max` that caused a memory leak (:issue:`25893`) - Bug in :meth:`pandas.core.window.Rolling.count` and `pandas.core.window.Expanding.count` was previously ignoring the axis keyword (:issue:`13503`) - +- Bug in :meth:`pandas.core.groupby.GroupBy.idxmax` and :meth:`pandas.core.groupby.GroupBy.idxmin` with datetime column would return incorrect dtype (:issue:`25444`, :issue:`15306`) +- Bug in :meth:`pandas.core.groupby.GroupBy.cumsum`, :meth:`pandas.core.groupby.GroupBy.cumprod`, :meth:`pandas.core.groupby.GroupBy.cummin` and :meth:`pandas.core.groupby.GroupBy.cummax` with categorical column having absent categories, would return incorrect result or segfault (:issue:`16771`) + Reshaping ^^^^^^^^^ From 5b879371a071ac9508acc494c10ab3896289cacc Mon Sep 17 00:00:00 2001 From: yhaque Date: Mon, 22 Apr 2019 13:24:49 -0400 Subject: [PATCH 15/25] DOC: GH26055 removed extra space --- doc/source/whatsnew/v0.25.0.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/doc/source/whatsnew/v0.25.0.rst b/doc/source/whatsnew/v0.25.0.rst index 681243e0da34a..3cb107715f8e7 100644 --- a/doc/source/whatsnew/v0.25.0.rst +++ b/doc/source/whatsnew/v0.25.0.rst @@ -393,7 +393,7 @@ Groupby/Resample/Rolling - Bug in :meth:`pandas.core.window.Rolling.count` and `pandas.core.window.Expanding.count` was previously ignoring the axis keyword (:issue:`13503`) - Bug in :meth:`pandas.core.groupby.GroupBy.idxmax` and :meth:`pandas.core.groupby.GroupBy.idxmin` with datetime column would return incorrect dtype (:issue:`25444`, :issue:`15306`) - Bug in :meth:`pandas.core.groupby.GroupBy.cumsum`, :meth:`pandas.core.groupby.GroupBy.cumprod`, :meth:`pandas.core.groupby.GroupBy.cummin` and :meth:`pandas.core.groupby.GroupBy.cummax` with categorical column having absent categories, would return incorrect result or segfault (:issue:`16771`) - + Reshaping ^^^^^^^^^ From 73208dc245fe9251bd9775ab9093c73e0bdc88e9 Mon Sep 17 00:00:00 2001 From: yhaque Date: Thu, 11 Apr 2019 16:21:03 -0400 Subject: [PATCH 16/25] Added axis to constructor call in count --- pandas/core/window.py | 1 + 1 file changed, 1 insertion(+) diff --git a/pandas/core/window.py b/pandas/core/window.py index 6b7b63a696fa0..6cca19fd2d5ae 100644 --- a/pandas/core/window.py +++ b/pandas/core/window.py @@ -939,6 +939,7 @@ def count(self): result = self._constructor(result, window=window, min_periods=0, axis=self.axis, center=self.center, + axis=self.axis, closed=self.closed).sum() results.append(result) From 126575756c8bec7f16d34f9db6d05061c203a2e3 Mon Sep 17 00:00:00 2001 From: yhaque Date: Mon, 22 Apr 2019 14:42:46 -0400 Subject: [PATCH 17/25] BUG: GH26055 removed extra assignment in constructor call --- pandas/core/window.py | 1 - 1 file changed, 1 deletion(-) diff --git a/pandas/core/window.py b/pandas/core/window.py index 6cca19fd2d5ae..7c7025498537d 100644 --- a/pandas/core/window.py +++ b/pandas/core/window.py @@ -937,7 +937,6 @@ def count(self): for b in blocks: result = b.notna().astype(int) result = self._constructor(result, window=window, min_periods=0, - axis=self.axis, center=self.center, axis=self.axis, closed=self.closed).sum() From a23c176e32c2dc38e34664678082081e62f8c6e8 Mon Sep 17 00:00:00 2001 From: yhaque Date: Mon, 22 Apr 2019 14:45:58 -0400 Subject: [PATCH 18/25] DOC: GH26055 removed rebase message --- doc/source/whatsnew/v0.25.0.rst | 3 --- 1 file changed, 3 deletions(-) diff --git a/doc/source/whatsnew/v0.25.0.rst b/doc/source/whatsnew/v0.25.0.rst index bc30e3dff4f40..823aab53624a1 100644 --- a/doc/source/whatsnew/v0.25.0.rst +++ b/doc/source/whatsnew/v0.25.0.rst @@ -409,10 +409,7 @@ Sparse - Significant speedup in :class:`SparseArray` initialization that benefits most operations, fixing performance regression introduced in v0.20.0 (:issue:`24985`) - Bug in :class:`SparseFrame` constructor where passing ``None`` as the data would cause ``default_fill_value`` to be ignored (:issue:`16807`) -<<<<<<< HEAD -======= - Bug in :class:`SparseDataFrame` when adding a column in which the length of values does not match length of index, ``AssertionError`` is raised instead of raising ``ValueError`` (:issue:`25484`) ->>>>>>> upstream/master Other From 3ba5d35ffa041b55403e083d930255615e43d79f Mon Sep 17 00:00:00 2001 From: yhaque Date: Fri, 26 Apr 2019 14:42:15 -0400 Subject: [PATCH 19/25] DOC: GH26055 removed typo from doc --- doc/source/whatsnew/v0.25.0.rst | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/doc/source/whatsnew/v0.25.0.rst b/doc/source/whatsnew/v0.25.0.rst index cf5a9e853d09e..bc30e3dff4f40 100644 --- a/doc/source/whatsnew/v0.25.0.rst +++ b/doc/source/whatsnew/v0.25.0.rst @@ -387,12 +387,9 @@ Groupby/Resample/Rolling - Ensured that ordering of outputs in ``groupby`` aggregation functions is consistent across all versions of Python (:issue:`25692`) - Ensured that result group order is correct when grouping on an ordered ``Categorical`` and specifying ``observed=True`` (:issue:`25871`, :issue:`25167`) - Bug in :meth:`pandas.core.window.Rolling.min` and :meth:`pandas.core.window.Rolling.max` that caused a memory leak (:issue:`25893`) -<<<<<<< HEAD -- Bug in :meth:`pandas.core.window.Rolling.count` and `pandas.core. window.Expanding.count` was previously ignoring the axis keyword (:issue:`13503`) -======= +- Bug in :meth:`pandas.core.window.Rolling.count` and `pandas.core.window.Expanding.count` was previously ignoring the axis keyword (:issue:`13503`) - Bug in :meth:`pandas.core.groupby.GroupBy.idxmax` and :meth:`pandas.core.groupby.GroupBy.idxmin` with datetime column would return incorrect dtype (:issue:`25444`, :issue:`15306`) - Bug in :meth:`pandas.core.groupby.GroupBy.cumsum`, :meth:`pandas.core.groupby.GroupBy.cumprod`, :meth:`pandas.core.groupby.GroupBy.cummin` and :meth:`pandas.core.groupby.GroupBy.cummax` with categorical column having absent categories, would return incorrect result or segfault (:issue:`16771`) ->>>>>>> upstream/master Reshaping ^^^^^^^^^ From 9b2b9604963532c29eeee0945b114e8a02b388eb Mon Sep 17 00:00:00 2001 From: yhaque Date: Thu, 11 Apr 2019 16:21:03 -0400 Subject: [PATCH 20/25] Added axis to constructor call in count --- pandas/core/window.py | 1 + 1 file changed, 1 insertion(+) diff --git a/pandas/core/window.py b/pandas/core/window.py index 6b7b63a696fa0..6cca19fd2d5ae 100644 --- a/pandas/core/window.py +++ b/pandas/core/window.py @@ -939,6 +939,7 @@ def count(self): result = self._constructor(result, window=window, min_periods=0, axis=self.axis, center=self.center, + axis=self.axis, closed=self.closed).sum() results.append(result) From b8a6cae3b28a7b040469b6dab728d6e82c7a05e9 Mon Sep 17 00:00:00 2001 From: yhaque Date: Mon, 22 Apr 2019 13:12:56 -0400 Subject: [PATCH 21/25] DOC: GH26055 removed extra doc lines --- doc/source/whatsnew/v0.25.0.rst | 2 -- 1 file changed, 2 deletions(-) diff --git a/doc/source/whatsnew/v0.25.0.rst b/doc/source/whatsnew/v0.25.0.rst index bc30e3dff4f40..ab263f7af1009 100644 --- a/doc/source/whatsnew/v0.25.0.rst +++ b/doc/source/whatsnew/v0.25.0.rst @@ -388,8 +388,6 @@ Groupby/Resample/Rolling - Ensured that result group order is correct when grouping on an ordered ``Categorical`` and specifying ``observed=True`` (:issue:`25871`, :issue:`25167`) - Bug in :meth:`pandas.core.window.Rolling.min` and :meth:`pandas.core.window.Rolling.max` that caused a memory leak (:issue:`25893`) - Bug in :meth:`pandas.core.window.Rolling.count` and `pandas.core.window.Expanding.count` was previously ignoring the axis keyword (:issue:`13503`) -- Bug in :meth:`pandas.core.groupby.GroupBy.idxmax` and :meth:`pandas.core.groupby.GroupBy.idxmin` with datetime column would return incorrect dtype (:issue:`25444`, :issue:`15306`) -- Bug in :meth:`pandas.core.groupby.GroupBy.cumsum`, :meth:`pandas.core.groupby.GroupBy.cumprod`, :meth:`pandas.core.groupby.GroupBy.cummin` and :meth:`pandas.core.groupby.GroupBy.cummax` with categorical column having absent categories, would return incorrect result or segfault (:issue:`16771`) Reshaping ^^^^^^^^^ From 34e30188a75ffdb13f434effbf4b5c488465e13d Mon Sep 17 00:00:00 2001 From: yhaque Date: Mon, 22 Apr 2019 13:22:18 -0400 Subject: [PATCH 22/25] DOC: GH26055 readded accidentally removed doc lines --- doc/source/whatsnew/v0.25.0.rst | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/doc/source/whatsnew/v0.25.0.rst b/doc/source/whatsnew/v0.25.0.rst index ab263f7af1009..587de0c6f9201 100644 --- a/doc/source/whatsnew/v0.25.0.rst +++ b/doc/source/whatsnew/v0.25.0.rst @@ -388,7 +388,9 @@ Groupby/Resample/Rolling - Ensured that result group order is correct when grouping on an ordered ``Categorical`` and specifying ``observed=True`` (:issue:`25871`, :issue:`25167`) - Bug in :meth:`pandas.core.window.Rolling.min` and :meth:`pandas.core.window.Rolling.max` that caused a memory leak (:issue:`25893`) - Bug in :meth:`pandas.core.window.Rolling.count` and `pandas.core.window.Expanding.count` was previously ignoring the axis keyword (:issue:`13503`) - +- Bug in :meth:`pandas.core.groupby.GroupBy.idxmax` and :meth:`pandas.core.groupby.GroupBy.idxmin` with datetime column would return incorrect dtype (:issue:`25444`, :issue:`15306`) +- Bug in :meth:`pandas.core.groupby.GroupBy.cumsum`, :meth:`pandas.core.groupby.GroupBy.cumprod`, :meth:`pandas.core.groupby.GroupBy.cummin` and :meth:`pandas.core.groupby.GroupBy.cummax` with categorical column having absent categories, would return incorrect result or segfault (:issue:`16771`) + Reshaping ^^^^^^^^^ From 36d1c4ea1c35dd975cdb9d3b67847f95e96d21d9 Mon Sep 17 00:00:00 2001 From: yhaque Date: Mon, 22 Apr 2019 13:24:49 -0400 Subject: [PATCH 23/25] DOC: GH26055 removed extra space --- doc/source/whatsnew/v0.25.0.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/doc/source/whatsnew/v0.25.0.rst b/doc/source/whatsnew/v0.25.0.rst index 587de0c6f9201..bc30e3dff4f40 100644 --- a/doc/source/whatsnew/v0.25.0.rst +++ b/doc/source/whatsnew/v0.25.0.rst @@ -390,7 +390,7 @@ Groupby/Resample/Rolling - Bug in :meth:`pandas.core.window.Rolling.count` and `pandas.core.window.Expanding.count` was previously ignoring the axis keyword (:issue:`13503`) - Bug in :meth:`pandas.core.groupby.GroupBy.idxmax` and :meth:`pandas.core.groupby.GroupBy.idxmin` with datetime column would return incorrect dtype (:issue:`25444`, :issue:`15306`) - Bug in :meth:`pandas.core.groupby.GroupBy.cumsum`, :meth:`pandas.core.groupby.GroupBy.cumprod`, :meth:`pandas.core.groupby.GroupBy.cummin` and :meth:`pandas.core.groupby.GroupBy.cummax` with categorical column having absent categories, would return incorrect result or segfault (:issue:`16771`) - + Reshaping ^^^^^^^^^ From 499d9109989d8a66e2facfd712a09a5b5c71d3c8 Mon Sep 17 00:00:00 2001 From: yhaque Date: Mon, 22 Apr 2019 14:42:46 -0400 Subject: [PATCH 24/25] BUG: GH26055 removed extra assignment in constructor call --- pandas/core/window.py | 1 - 1 file changed, 1 deletion(-) diff --git a/pandas/core/window.py b/pandas/core/window.py index 6cca19fd2d5ae..7c7025498537d 100644 --- a/pandas/core/window.py +++ b/pandas/core/window.py @@ -937,7 +937,6 @@ def count(self): for b in blocks: result = b.notna().astype(int) result = self._constructor(result, window=window, min_periods=0, - axis=self.axis, center=self.center, axis=self.axis, closed=self.closed).sum() From 2786a8c3cd66117841a3a71f63ceb1e272dbda59 Mon Sep 17 00:00:00 2001 From: yhaque Date: Mon, 22 Apr 2019 14:45:58 -0400 Subject: [PATCH 25/25] DOC: GH26055 removed rebase message --- doc/source/whatsnew/v0.25.0.rst | 3 --- 1 file changed, 3 deletions(-) diff --git a/doc/source/whatsnew/v0.25.0.rst b/doc/source/whatsnew/v0.25.0.rst index bc30e3dff4f40..823aab53624a1 100644 --- a/doc/source/whatsnew/v0.25.0.rst +++ b/doc/source/whatsnew/v0.25.0.rst @@ -409,10 +409,7 @@ Sparse - Significant speedup in :class:`SparseArray` initialization that benefits most operations, fixing performance regression introduced in v0.20.0 (:issue:`24985`) - Bug in :class:`SparseFrame` constructor where passing ``None`` as the data would cause ``default_fill_value`` to be ignored (:issue:`16807`) -<<<<<<< HEAD -======= - Bug in :class:`SparseDataFrame` when adding a column in which the length of values does not match length of index, ``AssertionError`` is raised instead of raising ``ValueError`` (:issue:`25484`) ->>>>>>> upstream/master Other