Dataframe BenchMEASURED IN ONE ENVIRONMENT

    ↑↓ to select, Enter to open, Esc to close

    pandas Series.rolling(50).mean() is ~2.74× slower than polars rolling_mean(50) for a 50-row rolling mean

    Same window, same column, same row order.

    Result

    Runpandas Series.rolling(50).mean()polars rolling_mean(50)Ratio
    Run 112.984.592.83×
    Run 212.364.562.71×
    Run 316.325.962.74×

    Spread over 3 runs: pandas Series.rolling(50).mean() CV 15.3% / polars rolling_mean(50) CV 15.8% / ratio CV 2.3%

    The two calls

    df['v'].rolling(50).mean()
    df['v'].rolling_mean(window_size=50)

    Conditions

    400,000 float values in the order they were generated.

    Where this number does not apply

    Rolling windows over grouped keys behave differently and are not measured here.

    Reproduce

    cd bench && python run.py --run 1 --out ../data/run1.json