-
-
Notifications
You must be signed in to change notification settings - Fork 18.4k
BUG: rolling.count with axis=1 #26055
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
tests pls |
Codecov Report
@@ Coverage Diff @@
## master #26055 +/- ##
==========================================
- Coverage 91.9% 91.89% -0.01%
==========================================
Files 175 175
Lines 52485 52485
==========================================
- Hits 48234 48231 -3
- Misses 4251 4254 +3
Continue to review full report at Codecov.
|
Codecov Report
@@ Coverage Diff @@
## master #26055 +/- ##
==========================================
- Coverage 91.98% 91.97% -0.02%
==========================================
Files 175 175
Lines 52371 52379 +8
==========================================
Hits 48175 48175
- Misses 4196 4204 +8
Continue to review full report at Codecov.
|
Hello @yhaque1213! Thanks for updating this PR. We checked the lines you've touched for PEP 8 issues, and found: There are currently no PEP 8 issues detected in this Pull Request. Cheers! 🍻 Comment last updated at 2019-04-26 18:51:18 UTC |
@gfyoung Once I added my tests, however, I started failing pandas-dev.pandas and pandas-dev.pandas (Linux py35_compat), and I'm having some trouble figuring out what's causing this to happen. More specifically, it seems to be an error with the Do you have any advice? |
@yhaque1213 : Have you merged / rebased onto the most recent |
@gfyoung : that seemed to do the trick - my latest update is passing all of the checks. Thank you, and please let me know if there's anything else you'd like me to add! |
@yhaque1213 : Don't forget the |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
pls add a whatsnew note as well; bug fixes groupby/rolling section
pandas/tests/test_window.py
Outdated
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) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
use
result=
expected=
tm.assert_frame_equal
so df_row looks like your expected
pandas/tests/test_window.py
Outdated
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]}) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
same here
pandas/tests/test_window.py
Outdated
@@ -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): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
rename this to test_rolling_axis_count, rename the test right above to test_rolling_axis_sum
doc/source/whatsnew/v0.25.0.rst
Outdated
@@ -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`) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this is not a public method, use :meth:`pandas.core.window.Rolling.count
and another for Expanding
doc/source/whatsnew/v0.25.0.rst
Outdated
@@ -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`) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this is also confusing over what you are saying, can you reword, something like '....was previously ignoring the axis
keyword'
pandas/tests/test_window.py
Outdated
@@ -667,6 +667,23 @@ 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): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
use the axis_frame fixture which resoles to rows/columns/0/1
I made the changes to the test and to the docs, but it seems like these Azure pipelines checks are passing arbitrarily. For instance, after fixing a typo in a comment (commit #12065b6) we passed 10/10 tests, while the previous commit only passed 8 (commit #41ae7fe). This happened even with rebasing before each push, therefore, we aren't sure what to change for this last commit to get it to pass all 10. |
CI is not 'arbitrary', rather there was an upstream change that broke things. |
pls merge master and ping on green. |
doc/source/whatsnew/v0.25.0.rst
Outdated
@@ -384,6 +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.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`) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
make a single entry here (just combine the lines)
pandas/tests/test_window.py
Outdated
|
||
axis = df._get_axis_number(axis_frame) | ||
|
||
if axis == 0: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this is not correct (should your test have broken?)
if axis in [0, 'index']
is what you need
@jreback : Just made the changes requested, and I'm passing all the checks now! |
I've made all of the changes that were requested, but I'm still having trouble getting all of the checks to pass. I've tried rebasing and merging multiple times, but nothing has been working |
try git merge upstream/master |
There's a failure in the doc checks that should be unrelated. Not sure if its a versioning thing or a commit to master. Taking a look now |
this was cleared yesterday |
Latest push was with merging with upstream/master, but it looks like the checks are still failing in the same ways as before. Sorry I'm not sure if I'm doing something wrong, but I've tried everything I could think of |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lgtm. tiny typo. pls rebase on master which is green now.
doc/source/whatsnew/v0.25.0.rst
Outdated
@@ -387,6 +387,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 :meth:`pandas.core.window.Rolling.count` and `pandas.core. window.Expanding.count` was previously ignoring the axis keyword (:issue:`13503`) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can you remove the space here pandas.core.window....
small typo plus can i merge master ; ping on green |
@jrebeck: I removed the typo - I'm passing all the checks now! |
thanks @yhaque1213 |
git diff upstream/master -u -- "*.py" | flake8 --diff
Added axis parameter to the constructor call in the count function, fixing the original issue in Rolling(axis='columns').count() ignores axis= keyword #13503. This fix works for the example given in the issue. This does not fix the problem addressed by jorisvandenbossche, as that seems to be a type issue.