Dataframe BenchMEASURED IN ONE ENVIRONMENT

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

    pandas sort_values is ~13.43× slower than polars sort for sorting 400,000 floats

    A single float column, ascending.

    Result

    Runpandas sort_valuespolars sortRatio
    Run 1194.0214.4413.43×
    Run 2199.2615.0413.25×
    Run 3193.9514.2313.63×

    Spread over 3 runs: pandas sort_values CV 1.6% / polars sort CV 2.9% / ratio CV 1.4%

    The two calls

    df.sort_values('v')
    df.sort('v')

    Conditions

    Random floats, 400,000 rows.

    Where this number does not apply

    A nearly sorted column changes the algorithm and the ratio.

    Reproduce

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