From 32fd35ac96362d2786cbdfb8f83c0495bb49c1a4 Mon Sep 17 00:00:00 2001 From: Richard Shadrach Date: Sat, 25 Oct 2025 09:12:22 -0400 Subject: [PATCH] PERF: Assign unique for monotonic but not strictly monotonic index --- pandas/_libs/index.pyx | 3 +++ 1 file changed, 3 insertions(+) diff --git a/pandas/_libs/index.pyx b/pandas/_libs/index.pyx index e6f59f8518754..f9e382285b408 100644 --- a/pandas/_libs/index.pyx +++ b/pandas/_libs/index.pyx @@ -321,6 +321,9 @@ cdef class IndexEngine: if is_strict_monotonic: self.unique = 1 self.need_unique_check = 0 + elif self.monotonic_inc == 1 or self.monotonic_dec == 1: + self.unique = 0 + self.need_unique_check = 0 cdef _call_monotonic(self, values): return algos.is_monotonic(values, timelike=False)