Skip to content

BUG: 43909 - check monoticity of rolling groupby #44068

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 26 commits into from
Dec 22, 2021

Conversation

jamesholcombe
Copy link
Contributor

@jamesholcombe jamesholcombe commented Oct 17, 2021

@pep8speaks
Copy link

pep8speaks commented Oct 17, 2021

Hello @jamesholcombe! 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 2021-12-22 13:40:13 UTC

@jamesholcombe jamesholcombe changed the title Dev bug BUG: 43909 - check monoticity of rolling groupby Oct 17, 2021
@jamesholcombe
Copy link
Contributor Author

@github-actions pre-commit

@jamesholcombe
Copy link
Contributor Author

This PR should close issue 43909. Previous behaviour of a rolling window on a groupby was inconsistent with behaviour of rolling window on a dataframe. The former raises an error for non-monotonic "on". I have amended the latter to match this behaviour.

@jamesholcombe
Copy link
Contributor Author

@github-actions pre-commit

@jreback jreback added the Window rolling, ewma, expanding label Oct 17, 2021
@jreback jreback added this to the 1.4 milestone Oct 17, 2021
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.

also needs a whatsnew note

def test_groupby_rolling_non_monotonic():
# GH 43909
shuffled = [3, 0, 1, 2]
sec = 1_000_000_000
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 use a smaller number here

result = df2.groupby("A").rolling("4s", on="B").C.mean()
tm.assert_series_equal(result, expected)
with pytest.raises(ValueError, match=r".* must be monotonic"):
df.groupby("A").rolling("4s", on="B").C.mean()
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 also add back the .sort_values(...) then a successful groupby / rolling

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

Copy link
Contributor

Choose a reason for hiding this comment

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

pls do this

Copy link
Contributor Author

Choose a reason for hiding this comment

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

the successful groupby with rolling is the test above

Copy link
Contributor

Choose a reason for hiding this comment

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

but its not the same as what you are doing. it fails, you sort then it works. this needs testing.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

agreed - amended in last push

@jamesholcombe
Copy link
Contributor Author

@github-actions pre-commit

@jamesholcombe
Copy link
Contributor Author

Whats New: Value Error now raised when a non-monotonic time series passed to "_on" attribute of a rolling groupby. This is to match the error raised for a rolling window on a dataframe. Tests have been added to confirm expected behaviour.

@jamesholcombe jamesholcombe requested a review from jreback October 19, 2021 21:53
@jamesholcombe
Copy link
Contributor Author

@github-actions pre-commit

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 also merge master

@jamesholcombe
Copy link
Contributor Author

@github-actions pre-commit

@jamesholcombe jamesholcombe requested a review from jreback October 24, 2021 20:20
@jamesholcombe
Copy link
Contributor Author

Hi Jeff,
master is merged no?
which sections require commenting?
Cheers

@jamesholcombe
Copy link
Contributor Author

@github-actions pre-commit

@jamesholcombe
Copy link
Contributor Author

NOTE: master branch contains breaking changes so have not merged most recent.

@jreback
Copy link
Contributor

jreback commented Oct 31, 2021

NOTE: master branch contains breaking changes so have not merged most recent.

what does this mean?

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.

can you add a whatsnew note. put in bug fixes for 1.4 in groupby section. ping on green .

@jreback
Copy link
Contributor

jreback commented Nov 14, 2021

still needs a whatsnew note and merge master

1 similar comment
@jreback
Copy link
Contributor

jreback commented Nov 28, 2021

still needs a whatsnew note and merge master

@jamesholcombe
Copy link
Contributor Author

@github-actions pre-commit

1 similar comment
@jamesholcombe
Copy link
Contributor Author

@github-actions pre-commit

@jamesholcombe
Copy link
Contributor Author

Find whats new note at top of PR. master merged.

@jamesholcombe
Copy link
Contributor Author

@github-actions pre-commit

@jreback
Copy link
Contributor

jreback commented Dec 11, 2021

whatsnew note goes in the doc/ folder under 1.4.0 for bug fixes

@jreback
Copy link
Contributor

jreback commented Dec 14, 2021

pre-commit is failing, pls merge master and ping on green.

@jamesholcombe
Copy link
Contributor Author

pre commit now passing

@jreback jreback merged commit b1827ea into pandas-dev:master Dec 22, 2021
@jreback
Copy link
Contributor

jreback commented Dec 22, 2021

thanks @jamesholcombe

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Window rolling, ewma, expanding
Projects
None yet
Development

Successfully merging this pull request may close these issues.

BUG: Using df.groupby(..).rolling(..) on non-monotonic timestamp column does not raise an exception
3 participants