Skip to content

Commit 30ca7ae

Browse files
committed
BUG: Accept kwargs kind and na_position in Series.sort_index (GH13589)
1 parent 1ce8f8e commit 30ca7ae

File tree

2 files changed

+8
-3
lines changed

2 files changed

+8
-3
lines changed

doc/source/whatsnew/v0.19.0.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -731,3 +731,5 @@ Bug Fixes
731731
- Bug where ``pd.read_gbq()`` could throw ``ImportError: No module named discovery`` as a result of a naming conflict with another python package called apiclient (:issue:`13454`)
732732
- Bug in ``Index.union`` returns an incorrect result with a named empty index (:issue:`13432`)
733733
- Bugs in ``Index.difference`` and ``DataFrame.join`` raise in Python3 when using mixed-integer indexes (:issue:`13432`, :issue:`12814`)
734+
735+
- Bug in ``Series.sort_index`` didn't accept kwargs ``kind`` and ``na_position`` (:issue:`13589`)

pandas/core/series.py

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1756,7 +1756,7 @@ def _try_kind_sort(arr):
17561756

17571757
@Appender(generic._shared_docs['sort_index'] % _shared_doc_kwargs)
17581758
def sort_index(self, axis=0, level=None, ascending=True, inplace=False,
1759-
sort_remaining=True):
1759+
kind='quicksort', na_position='last', sort_remaining=True):
17601760

17611761
axis = self._get_axis_number(axis)
17621762
index = self.index
@@ -1765,12 +1765,15 @@ def sort_index(self, axis=0, level=None, ascending=True, inplace=False,
17651765
sort_remaining=sort_remaining)
17661766
elif isinstance(index, MultiIndex):
17671767
from pandas.core.groupby import _lexsort_indexer
1768-
indexer = _lexsort_indexer(index.labels, orders=ascending)
1768+
indexer = _lexsort_indexer(index.labels, orders=ascending,
1769+
na_position=na_position)
17691770
indexer = _ensure_platform_int(indexer)
17701771
new_index = index.take(indexer)
17711772
else:
17721773
new_index, indexer = index.sort_values(return_indexer=True,
1773-
ascending=ascending)
1774+
ascending=ascending,
1775+
kind=kind,
1776+
na_position=na_position)
17741777

17751778
new_values = self._values.take(indexer)
17761779
result = self._constructor(new_values, index=new_index)

0 commit comments

Comments
 (0)