Skip to content

Commit cc67b9a

Browse files
author
tp
committed
added explanation for return value of MultiIndex.get_level_values
1 parent 8bfeec3 commit cc67b9a

File tree

3 files changed

+5
-4
lines changed

3 files changed

+5
-4
lines changed

pandas/core/indexes/base.py

+2-3
Original file line numberDiff line numberDiff line change
@@ -2534,14 +2534,13 @@ def _get_level_values(self, level):
25342534
Parameters
25352535
----------
25362536
level : int or str
2537-
``level`` is either the integer position of the level in the
2537+
``level`` is either the integer position of the level in the
25382538
MultiIndex, or the name of the level.
25392539
25402540
Returns
25412541
-------
25422542
values : Index
2543-
Because there is only one level when the index has one level,
2544-
the return value is always self in this case.
2543+
``self``, as there is only one level in the Index.
25452544
25462545
See also
25472546
---------

pandas/core/indexes/multi.py

+2
Original file line numberDiff line numberDiff line change
@@ -893,6 +893,8 @@ def get_level_values(self, level):
893893
Returns
894894
-------
895895
values : Index
896+
``values`` is a level of this MultiIndex converted to
897+
a single :class:`Index` (or subclass thereof).
896898
897899
Examples
898900
---------

pandas/tests/indexes/test_base.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -1438,7 +1438,7 @@ def test_get_level_values(self):
14381438
result = self.strIndex.get_level_values(0)
14391439
tm.assert_index_equal(result, self.strIndex)
14401440

1441-
# GH 17414
1441+
# test for name (GH 17414)
14421442
index_with_name = self.strIndex.copy()
14431443
index_with_name.name = 'a'
14441444
result = index_with_name.get_level_values('a')

0 commit comments

Comments
 (0)