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

Method test_sortlevel

pandas/tests/indexes/test_base.py:1297–1320  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

1295 index.contains(1)
1296
1297 def test_sortlevel(self):
1298 index = Index([5, 4, 3, 2, 1])
1299 with pytest.raises(Exception, match="ascending must be a single bool value or"):
1300 index.sortlevel(ascending="True")
1301
1302 with pytest.raises(
1303 Exception, match="ascending must be a list of bool values of length 1"
1304 ):
1305 index.sortlevel(ascending=[True, True])
1306
1307 with pytest.raises(Exception, match="ascending must be a bool value"):
1308 index.sortlevel(ascending=["True"])
1309
1310 expected = Index([1, 2, 3, 4, 5])
1311 result = index.sortlevel(ascending=[True])
1312 tm.assert_index_equal(result[0], expected)
1313
1314 expected = Index([1, 2, 3, 4, 5])
1315 result = index.sortlevel(ascending=True)
1316 tm.assert_index_equal(result[0], expected)
1317
1318 expected = Index([5, 4, 3, 2, 1])
1319 result = index.sortlevel(ascending=False)
1320 tm.assert_index_equal(result[0], expected)
1321
1322 def test_sortlevel_na_position(self):
1323 # GH#51612

Callers

nothing calls this directly

Calls 3

sortlevelMethod · 0.95
IndexClass · 0.85
raisesMethod · 0.45

Tested by

no test coverage detected