Dataframe BenchMEASURED IN ONE ENVIRONMENT

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

    pandas dt.month is ~2.34× slower than polars dt.month() for extracting the month from a date

    The date column is already parsed on both sides before timing starts.

    Result

    Runpandas dt.monthpolars dt.month()Ratio
    Run 112.945.622.30×
    Run 213.275.672.34×
    Run 315.496.432.41×

    Spread over 3 runs: pandas dt.month CV 10.0% / polars dt.month() CV 7.7% / ratio CV 2.2%

    The two calls

    df['dt'].dt.month
    df['dt'].dt.month()

    Conditions

    Dates span 2024-01-01 to 2024-12-28.

    Where this number does not apply

    Parsing the strings inside the timed block would change the result completely.

    Reproduce

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