Skip to content

PERF: Regression in Series.is_monotonic_increasing for categorical #33365

Closed
@TomAugspurger

Description

@TomAugspurger
  • I have checked that this issue has not already been reported.

  • I have confirmed this bug exists on the latest version of pandas.

  • (optional) I have confirmed this bug exists on the master branch of pandas.


Code Sample, a copy-pastable example

Pandas 1.0.1

In [2]: N = 1000

In [3]: c = pd.CategoricalIndex(list("a" * N + "b" * N + "c" * N))

In [4]: s = pd.Series(c)

In [5]: %timeit s.is_monotonic_increasing
35.3 µs ± 663 ns per loop (mean ± std. dev. of 7 runs, 10000 loops each)

Master

In [5]: %timeit s.is_monotonic_increasing
73.6 µs ± 782 ns per loop (mean ± std. dev. of 7 runs, 10000 loops each)

Problem description

https://pandas.pydata.org/speed/pandas/#categoricals.IsMonotonic.time_categorical_series_is_monotonic_increasing

Metadata

Metadata

Assignees

No one assigned

    Labels

    AlgosNon-arithmetic algos: value_counts, factorize, sorting, isin, clip, shift, diffCategoricalCategorical Data TypePerformanceMemory or execution speed performanceRegressionFunctionality that used to work in a prior pandas version

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions