Skip to content

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

Closed
@leftys

Description

@leftys

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    BugWindowrolling, ewma, expanding

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions