MCPcopy
hub / github.com/pandas-dev/pandas / test_sort_values

Method test_sort_values

pandas/tests/extension/base/methods.py:214–225  ·  view source on GitHub ↗
(self, data_for_sorting, ascending, sort_by_key)

Source from the content-addressed store, hash-verified

212
213 @pytest.mark.parametrize("ascending", [True, False])
214 def test_sort_values(self, data_for_sorting, ascending, sort_by_key):
215 ser = pd.Series(data_for_sorting)
216 result = ser.sort_values(ascending=ascending, key=sort_by_key)
217 expected = ser.iloc[[2, 0, 1]]
218 if not ascending:
219 # GH 35922. Expect stable sort
220 if ser.nunique() == 2:
221 expected = ser.iloc[[0, 1, 2]]
222 else:
223 expected = ser.iloc[[1, 0, 2]]
224
225 tm.assert_series_equal(result, expected)
226
227 @pytest.mark.parametrize("ascending", [True, False])
228 def test_sort_values_missing(

Callers

nothing calls this directly

Calls 2

sort_valuesMethod · 0.95
nuniqueMethod · 0.45

Tested by

no test coverage detected