>> n = 1000000 >>> ci = pd.CategoricalIndex(list('a' * n + 'b' * n + '...">

PERF: improved performance of CategoricalIndex.is_monotonic* by topper-123 · Pull Request #21025 · pandas-dev/pandas (original) (raw)

There were no asv's for this. However, if you run my code snippet above, there is a huge spike in RAM usage, when run in the old version. I've even gotten a few MemoryErrors.

So my ASV is done using only N = 1000 to limit memory usage. The result is here 60 microseconds (old version) vs 260 ns (new version).

Also, Series.is_monotonic* wasn't added untill 0.19. should that be put in a try/except clause, to avoid failing on older versions of pandas?