Skip to content

Commit 3378b3a

Browse files
author
tp
committed
imroved performance of CategoricalIndex.is_monotonic*
1 parent a5c02d5 commit 3378b3a

File tree

2 files changed

+3
-2
lines changed

2 files changed

+3
-2
lines changed

doc/source/whatsnew/v0.23.0.txt

+1
Original file line numberDiff line numberDiff line change
@@ -1079,6 +1079,7 @@ Performance Improvements
10791079
- Improved performance of :func:`pandas.core.groupby.GroupBy.pct_change` (:issue:`19165`)
10801080
- Improved performance of :func:`Series.isin` in the case of categorical dtypes (:issue:`20003`)
10811081
- Improved performance of ``getattr(Series, attr)`` when the Series has certain index types. This manifiested in slow printing of large Series with a ``DatetimeIndex`` (:issue:`19764`)
1082+
- Improved performance of :meth:`CategoricalIndex.is_monotonic_increasing`, :meth:`CategoricalIndex.is_monotonic_decreasing` and :meth:`CategoricalIndex.is_monotonic` (:issue:`21025`)
10821083
- Fixed a performance regression for :func:`GroupBy.nth` and :func:`GroupBy.last` with some object columns (:issue:`19283`)
10831084

10841085
.. _whatsnew_0230.docs:

pandas/core/indexes/category.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -382,11 +382,11 @@ def is_unique(self):
382382

383383
@property
384384
def is_monotonic_increasing(self):
385-
return Index(self.codes).is_monotonic_increasing
385+
return self._engine.is_monotonic_increasing
386386

387387
@property
388388
def is_monotonic_decreasing(self):
389-
return Index(self.codes).is_monotonic_decreasing
389+
return self._engine.is_monotonic_decreasing
390390

391391
@Appender(_index_shared_docs['index_unique'] % _index_doc_kwargs)
392392
def unique(self, level=None):

0 commit comments

Comments
 (0)