Skip to content

Commit 0f1c9c5

Browse files
jbrockmendeljreback
authored andcommitted
remove duplicate is_lexsorted function (#19305)
1 parent 93dd55e commit 0f1c9c5

File tree

2 files changed

+2
-34
lines changed

2 files changed

+2
-34
lines changed

pandas/_libs/lib.pyx

-32
Original file line numberDiff line numberDiff line change
@@ -896,38 +896,6 @@ def write_csv_rows(list data, ndarray data_index,
896896
# ------------------------------------------------------------------------------
897897
# Groupby-related functions
898898

899-
@cython.wraparound(False)
900-
@cython.boundscheck(False)
901-
def is_lexsorted(list list_of_arrays):
902-
cdef:
903-
int i
904-
Py_ssize_t n, nlevels
905-
int64_t k, cur, pre
906-
ndarray arr
907-
908-
nlevels = len(list_of_arrays)
909-
n = len(list_of_arrays[0])
910-
911-
cdef int64_t **vecs = <int64_t**> malloc(nlevels * sizeof(int64_t*))
912-
for i from 0 <= i < nlevels:
913-
arr = list_of_arrays[i]
914-
vecs[i] = <int64_t *> arr.data
915-
916-
# Assume uniqueness??
917-
for i from 1 <= i < n:
918-
for k from 0 <= k < nlevels:
919-
cur = vecs[k][i]
920-
pre = vecs[k][i - 1]
921-
if cur == pre:
922-
continue
923-
elif cur > pre:
924-
break
925-
else:
926-
return False
927-
free(vecs)
928-
return True
929-
930-
931899
# TODO: could do even better if we know something about the data. eg, index has
932900
# 1-min data, binner has 5-min data, then bins are just strides in index. This
933901
# is a general, O(max(len(values), len(binner))) method.

pandas/core/indexes/multi.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
from sys import getsizeof
66

77
import numpy as np
8-
from pandas._libs import index as libindex, lib, Timestamp
8+
from pandas._libs import algos as libalgos, index as libindex, lib, Timestamp
99

1010
from pandas.compat import range, zip, lrange, lzip, map
1111
from pandas.compat.numpy import function as nv
@@ -1137,7 +1137,7 @@ def lexsort_depth(self):
11371137

11381138
int64_labels = [_ensure_int64(lab) for lab in self.labels]
11391139
for k in range(self.nlevels, 0, -1):
1140-
if lib.is_lexsorted(int64_labels[:k]):
1140+
if libalgos.is_lexsorted(int64_labels[:k]):
11411141
return k
11421142

11431143
return 0

0 commit comments

Comments
 (0)