Skip to content

Commit d8cf791

Browse files
committed
TST: GH26055 fixed docs description and added axis_frame to test
1 parent 12bafb2 commit d8cf791

File tree

2 files changed

+10
-11
lines changed

2 files changed

+10
-11
lines changed

doc/source/whatsnew/v0.25.0.rst

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -389,7 +389,8 @@ Groupby/Resample/Rolling
389389
- Ensured that result group order is correct when grouping on an ordered ``Categorical`` and specifying ``observed=True`` (:issue:`25871`, :issue:`25167`)
390390
- Bug in :meth:`pandas.core.window.Rolling.min` and :meth:`pandas.core.window.Rolling.max` that caused a memory leak (:issue:`25893`)
391391
- Bug in :func:`idxmax` and :func:`idxmin` on :meth:`DataFrame.groupby` with datetime column would return incorrect dtype (:issue:`25444`, :issue:`15306`)
392-
- Bug in :meth:`pandas.core.window._Rolling_and_Expanding.count` that did not include axis parameter in constructor call (:issue:`13503`)
392+
- Bug in :meth:`pandas.core.window.Rolling.count` was previously ignoring the axis keyword (:issue:`13503`)
393+
- Bug in :meth:`pandas.core.window.Expanding.count` was previously ignoring the axis keyword (:issue:`13503`)
393394

394395
Reshaping
395396
^^^^^^^^^

pandas/tests/test_window.py

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -667,21 +667,19 @@ def test_rolling_axis_sum(self, axis_frame):
667667
result = df.rolling(3, axis=axis_frame).sum()
668668
tm.assert_frame_equal(result, expected)
669669

670-
def test_rolling_axis_count(self):
670+
def test_rolling_axis_count(self, axis_frame):
671671
# see gh-26055
672672
df = DataFrame({'x': range(3), 'y': range(3)})
673673

674-
result = df.rolling(2).count()
675-
expected = DataFrame({'x': [1.0, 2.0, 2.0], 'y': [1.0, 2.0, 2.0]})
676-
tm.assert_frame_equal(result, expected)
674+
axis = df._get_axis_number(axis_frame)
677675

678-
# not specifiying axis and making axis=rows
679-
# are expected to yield the same result
680-
result = df.rolling(2, axis='rows').count()
681-
tm.assert_frame_equal(result, expected)
676+
if axis == 0:
677+
expected = DataFrame({'x': [1.0, 2.0, 2.0], 'y': [1.0, 2.0, 2.0]})
678+
else:
679+
# axis == 1
680+
expected = DataFrame({'x': [1.0, 1.0, 1.0], 'y': [2.0, 2.0, 2.0]})
682681

683-
result = df.rolling(2, axis='columns').count()
684-
expected = DataFrame({'x': [1.0, 1.0, 1.0], 'y': [2.0, 2.0, 2.0]})
682+
result = df.rolling(2, axis=axis_frame).count()
685683
tm.assert_frame_equal(result, expected)
686684

687685

0 commit comments

Comments
 (0)