Skip to content

BUG: Fix Rolling where duplicate datetimelike indexes are treated as consecutive rather than equal with closed='left' and closed='neither' #54917

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

Conversation

ihsansecer
Copy link
Contributor

@ihsansecer ihsansecer commented Sep 1, 2023

@ihsansecer ihsansecer requested a review from WillAyd as a code owner September 1, 2023 00:04
@@ -466,20 +466,23 @@ def test_groupby_rolling_subset_with_closed(self):
# GH 35549
df = DataFrame(
{
"column1": range(6),
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Modified these two tests as the result would be list of nan values

@mroeschke mroeschke added the Window rolling, ewma, expanding label Sep 1, 2023
@@ -138,7 +138,12 @@ def calculate_variable_window_bounds(
break
# end bound is previous end
# or current index
elif (index[end[i - 1]] - end_bound) * index_growth_sign <= 0:
elif index[end[i - 1]] == end_bound:
Copy link
Member

Choose a reason for hiding this comment

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

Could you make a similar test for VariableOffsetWindowIndexer.get_window_bounds and include a test?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done

@mroeschke mroeschke added this to the 2.2 milestone Sep 5, 2023
@mroeschke mroeschke merged commit e7a1f9d into pandas-dev:main Sep 5, 2023
@mroeschke
Copy link
Member

Thanks @ihsansecer

mroeschke pushed a commit to mroeschke/pandas that referenced this pull request Sep 11, 2023
…consecutive rather than equal with closed='left' and closed='neither' (pandas-dev#54917)

* Add bugfix for rolling window with nonunique datetimelike index

* Run black

* Add entry to whatsnew

* Fix VariableOffsetWindowIndexer

* Simplify change in indexers.pyx

* Add test
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.

Rolling sum (closed='left') with duplicate Timestamp indices.
2 participants