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

Function test_changing_names

pandas/tests/indexes/multi/test_names.py:29–48  ·  view source on GitHub ↗
(idx)

Source from the content-addressed store, hash-verified

27
28
29def test_changing_names(idx):
30 assert [level.name for level in idx.levels] == ["first", "second"]
31
32 view = idx.view()
33 copy = idx.copy()
34 shallow_copy = idx._view()
35
36 # changing names should not change level names on object
37 new_names = [name + "a" for name in idx.names]
38 idx.names = new_names
39 check_level_names(idx, ["firsta", "seconda"])
40
41 # and not on copies
42 check_level_names(view, ["first", "second"])
43 check_level_names(copy, ["first", "second"])
44 check_level_names(shallow_copy, ["first", "second"])
45
46 # and copies shouldn't change original
47 shallow_copy.names = [name + "c" for name in shallow_copy.names]
48 check_level_names(idx, ["firsta", "seconda"])
49
50
51def test_take_preserve_name(idx):

Callers

nothing calls this directly

Calls 4

check_level_namesFunction · 0.85
viewMethod · 0.45
copyMethod · 0.45
_viewMethod · 0.45

Tested by

no test coverage detected