Skip to content

Commit 47b42ea

Browse files
committed
Add tests for testing na_position and kind kwargs in Series.sort_index
1 parent 30ca7ae commit 47b42ea

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

pandas/tests/series/test_sorting.py

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -144,3 +144,19 @@ def test_sort_index_multiindex(self):
144144
# rows share same level='A': sort has no effect without remaining lvls
145145
res = s.sort_index(level='A', sort_remaining=False)
146146
assert_series_equal(s, res)
147+
148+
def test_sort_index_nan(self):
149+
150+
# GH13729
151+
nan = np.nan
152+
ser = Series(['A', nan, 'C', 'D'], [1, 2, 0, nan])
153+
154+
# na_position='last', kind='quicksort'
155+
sorted_series = ser.sort_index(kind='quicksort', na_position='last')
156+
expected_series = Series(['C', 'A', nan, 'D'], [0, 1, 2, nan])
157+
assert_series_equal(sorted_series, expected_series)
158+
159+
# na_position='first'
160+
sorted_series = ser.sort_index(na_position='first')
161+
expected_series = Series(['D', 'C', 'A', nan], [nan, 0, 1, 2])
162+
assert_series_equal(sorted_series, expected_series)

0 commit comments

Comments
 (0)