Skip to content

Commit bd17d2b

Browse files
committed
rename sort_index_montonic -> _sort_index_monotonic
doc fixups
1 parent 31097fc commit bd17d2b

File tree

6 files changed

+11
-12
lines changed

6 files changed

+11
-12
lines changed

pandas/core/frame.py

+1-2
Original file line numberDiff line numberDiff line change
@@ -3349,8 +3349,7 @@ def sort_index(self, axis=0, level=None, ascending=True, inplace=False,
33493349

33503350
# make sure that the axis is lexsorted to start
33513351
# if not we need to reconstruct to get the correct indexer
3352-
labels = labels.sort_levels_monotonic()
3353-
3352+
labels = labels._sort_levels_monotonic()
33543353
indexer = lexsort_indexer(labels.labels, orders=ascending,
33553354
na_position=na_position)
33563355
else:

pandas/core/series.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -1762,7 +1762,7 @@ def sort_index(self, axis=0, level=None, ascending=True, inplace=False,
17621762
sort_remaining=sort_remaining)
17631763
elif isinstance(index, MultiIndex):
17641764
from pandas.core.sorting import lexsort_indexer
1765-
labels = index.sort_levels_monotonic()
1765+
labels = index._sort_levels_monotonic()
17661766
indexer = lexsort_indexer(labels.labels, orders=ascending)
17671767
else:
17681768
from pandas.core.sorting import nargsort

pandas/indexes/multi.py

+4-4
Original file line numberDiff line numberDiff line change
@@ -1173,7 +1173,7 @@ def from_product(cls, iterables, sortorder=None, names=None):
11731173
labels = cartesian_product(labels)
11741174
return MultiIndex(levels, labels, sortorder=sortorder, names=names)
11751175

1176-
def sort_levels_monotonic(self):
1176+
def _sort_levels_monotonic(self):
11771177
"""
11781178
.. versionadded:: 0.20.0
11791179
@@ -1236,15 +1236,15 @@ def sort_levels_monotonic(self):
12361236

12371237
def remove_unused_levels(self):
12381238
"""
1239-
.. versionadded:: 0.20.0
1240-
1241-
create a new MultiIndex from the current that removesing
1239+
create a new MultiIndex from the current that removing
12421240
unused levels, meaning that they are not expressed in the labels
12431241
12441242
The resulting MultiIndex will have the same outward
12451243
appearance, meaning the same .values and ordering. It will also
12461244
be .equals() to the original.
12471245
1246+
.. versionadded:: 0.20.0
1247+
12481248
Returns
12491249
-------
12501250
MultiIndex

pandas/tests/indexes/test_multi.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -2420,7 +2420,7 @@ def test_reconstruct_sort(self):
24202420
assert mi.is_lexsorted()
24212421
assert mi.is_monotonic
24222422

2423-
recons = mi.sort_levels_monotonic()
2423+
recons = mi._sort_levels_monotonic()
24242424
assert recons.is_lexsorted()
24252425
assert recons.is_monotonic
24262426
assert mi is recons
@@ -2435,7 +2435,7 @@ def test_reconstruct_sort(self):
24352435
assert not mi.is_lexsorted()
24362436
assert not mi.is_monotonic
24372437

2438-
recons = mi.sort_levels_monotonic()
2438+
recons = mi._sort_levels_monotonic()
24392439
assert not recons.is_lexsorted()
24402440
assert not recons.is_monotonic
24412441

@@ -2449,7 +2449,7 @@ def test_reconstruct_sort(self):
24492449
assert not mi.is_lexsorted()
24502450
assert not mi.is_monotonic
24512451

2452-
recons = mi.sort_levels_monotonic()
2452+
recons = mi._sort_levels_monotonic()
24532453
assert not recons.is_lexsorted()
24542454
assert not recons.is_monotonic
24552455

pandas/tests/test_multilevel.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -2582,7 +2582,7 @@ def test_sort_index_and_reconstruction_doc_example(self):
25822582

25832583
# reconstruct
25842584
result = df.sort_index().copy()
2585-
result.index = result.index.sort_levels_monotonic()
2585+
result.index = result.index._sort_levels_monotonic()
25862586
assert result.index.is_lexsorted()
25872587
assert result.index.is_monotonic
25882588

pandas/tests/tools/test_hashing.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ def test_multiindex_objects(self):
9191
mi = MultiIndex(levels=[['b', 'd', 'a'], [1, 2, 3]],
9292
labels=[[0, 1, 0, 2], [2, 0, 0, 1]],
9393
names=['col1', 'col2'])
94-
recons = mi.sort_levels_monotonic()
94+
recons = mi._sort_levels_monotonic()
9595

9696
# these are equal
9797
assert mi.equals(recons)

0 commit comments

Comments
 (0)