Skip to content

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

Merged
merged 31 commits into from
Apr 28, 2019
Merged

Conversation

yhaque1213
Copy link
Contributor

@yhaque1213 yhaque1213 commented Apr 11, 2019

@jreback
Copy link
Contributor

jreback commented Apr 11, 2019

tests pls

@codecov
Copy link

codecov bot commented Apr 11, 2019

Codecov Report

Merging #26055 into master will decrease coverage by <.01%.
The diff coverage is n/a.

Impacted file tree graph

@@            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
Flag Coverage Δ
#multiple 90.45% <ø> (ø) ⬆️
#single 40.75% <ø> (-0.14%) ⬇️
Impacted Files Coverage Δ
pandas/core/window.py 96.39% <ø> (ø) ⬆️
pandas/io/gbq.py 75% <0%> (-12.5%) ⬇️
pandas/core/frame.py 96.79% <0%> (-0.12%) ⬇️
pandas/util/testing.py 90.72% <0%> (+0.1%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update a07ed59...da47224. Read the comment docs.

@codecov
Copy link

codecov bot commented Apr 11, 2019

Codecov Report

Merging #26055 into master will decrease coverage by 0.01%.
The diff coverage is n/a.

Impacted file tree graph

@@            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
Flag Coverage Δ
#multiple 90.52% <ø> (-0.01%) ⬇️
#single 40.69% <ø> (-0.16%) ⬇️
Impacted Files Coverage Δ
pandas/core/window.py 96.39% <ø> (ø) ⬆️
pandas/io/gbq.py 78.94% <0%> (-10.53%) ⬇️
pandas/core/indexing.py 90.53% <0%> (-0.35%) ⬇️
pandas/core/computation/engines.py 88.33% <0%> (-0.2%) ⬇️
pandas/core/frame.py 96.9% <0%> (-0.12%) ⬇️
pandas/core/indexes/base.py 96.94% <0%> (-0.06%) ⬇️
pandas/core/reshape/pivot.py 96.54% <0%> (ø) ⬆️
pandas/io/packers.py 88.08% <0%> (ø) ⬆️
pandas/core/indexes/interval.py 95.22% <0%> (ø) ⬆️
pandas/core/sparse/series.py 93.3% <0%> (ø) ⬆️
... and 22 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update fecee8f...d040376. Read the comment docs.

@pep8speaks
Copy link

pep8speaks commented Apr 12, 2019

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 gfyoung added Bug Reshaping Concat, Merge/Join, Stack/Unstack, Explode labels Apr 12, 2019
@jreback jreback changed the title Fixed issue #13503 BUG: rolling.count with axis=1 Apr 12, 2019
@yhaque1213
Copy link
Contributor Author

@gfyoung
I updated the tests to replace my calls to assert_equal with tm.assert_frame_equal, and I also modified it to pass pep8 checks. My initial changes to fix the issue, without any tests, was passing all of the builds.

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 test_drop_duplicates_categorical_non_bool in pandas/tests/series/test_analytics.py, but I have no idea why this specific test would be failing because of adding my test, test_count_axis.

Do you have any advice?

@gfyoung
Copy link
Member

gfyoung commented Apr 13, 2019

@yhaque1213 : Have you merged / rebased onto the most recent master? Try that and see if it goes away. Otherwise, we'll look into seeing if we can remove (or weaken) the xfail on those tests.

@yhaque1213
Copy link
Contributor Author

@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!

@gfyoung
Copy link
Member

gfyoung commented Apr 16, 2019

@yhaque1213 : Don't forget the whatsnew entry!

Copy link
Contributor

@jreback jreback left a 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

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)
Copy link
Contributor

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

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]})
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same here

@@ -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):
Copy link
Contributor

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

@@ -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`)
Copy link
Contributor

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

@@ -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`)
Copy link
Contributor

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'

@@ -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):
Copy link
Contributor

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

@yhaque1213
Copy link
Contributor Author

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.

@jreback
Copy link
Contributor

jreback commented Apr 20, 2019

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.

@jreback
Copy link
Contributor

jreback commented Apr 20, 2019

pls merge master and ping on green.

@@ -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`)
Copy link
Contributor

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)


axis = df._get_axis_number(axis_frame)

if axis == 0:
Copy link
Contributor

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

@yhaque1213
Copy link
Contributor Author

@jreback : Just made the changes requested, and I'm passing all the checks now!

@yhaque1213
Copy link
Contributor Author

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

@jreback
Copy link
Contributor

jreback commented Apr 22, 2019

try

git merge upstream/master

@WillAyd
Copy link
Member

WillAyd commented Apr 22, 2019

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

@jreback
Copy link
Contributor

jreback commented Apr 22, 2019

this was cleared yesterday

@yhaque1213
Copy link
Contributor Author

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

Copy link
Contributor

@jreback jreback left a 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.

@@ -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`)
Copy link
Contributor

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....

@jreback
Copy link
Contributor

jreback commented Apr 26, 2019

small typo plus can i merge master ; ping on green

@yhaque1213
Copy link
Contributor Author

@jrebeck: I removed the typo - I'm passing all the checks now!

@jreback jreback merged commit 48ea04f into pandas-dev:master Apr 28, 2019
@jreback
Copy link
Contributor

jreback commented Apr 28, 2019

thanks @yhaque1213

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug Reshaping Concat, Merge/Join, Stack/Unstack, Explode
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Rolling(axis='columns').count() ignores axis= keyword
5 participants