Skip to content

BUG: Rolling functions doesn't work on decreasing variable index #32385

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

Closed
leftys opened this issue Mar 1, 2020 · 1 comment · Fixed by #32386
Closed

BUG: Rolling functions doesn't work on decreasing variable index #32385

leftys opened this issue Mar 1, 2020 · 1 comment · Fixed by #32386
Labels
Bug Window rolling, ewma, expanding
Milestone

Comments

@leftys
Copy link
Contributor

leftys commented Mar 1, 2020

Code Sample

    def test_rolling_on_decreasing_index(self):
        # GH-19248
        index = [
            Timestamp("20190101 09:00:00"),
            Timestamp("20190101 09:00:02"),
            Timestamp("20190101 09:00:03"),
            Timestamp("20190101 09:00:05"),
            Timestamp("20190101 09:00:06"),
        ]

        df = DataFrame({"column": [3, 4, 4, 2, 1]}, index=reversed(index))
        result = df.rolling("2s").min()
        expected = DataFrame(
            {"column": [3.0, 4.0, 4.0, 2.0, 1.0]}, index=reversed(index)
        )
        # actual incorrect output is [3, 3, 3, 2, 1]
        tm.assert_frame_equal(result, expected)

Problem description

Rolling window operations on variable decreasing index don't work even after #28297. The reason for this is that the calculate_variable_window_bounds function doesn't work with decreasing index. Tested with latest master (~version 1.0.1).

@leftys leftys changed the title Rolling functions doesn't work on decreasing variable index BUG: Rolling functions doesn't work on decreasing variable index Mar 1, 2020
@jorisvandenbossche jorisvandenbossche added this to the 1.0.2 milestone Mar 2, 2020
@jorisvandenbossche jorisvandenbossche added the Window rolling, ewma, expanding label Mar 2, 2020
@jorisvandenbossche
Copy link
Member

Thanks for the report (and the PR)!

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

Successfully merging a pull request may close this issue.

2 participants