Skip to content

Commit 66c5b9a

Browse files
DOC: fix SA01 for pandas.MultiIndex.get_level_values (#59400)
Co-authored-by: Matthew Roeschke <[email protected]>
1 parent 81a12dd commit 66c5b9a

File tree

2 files changed

+17
-1
lines changed

2 files changed

+17
-1
lines changed

ci/code_checks.sh

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,6 @@ if [[ -z "$CHECK" || "$CHECK" == "docstrings" ]]; then
7070
--format=actions \
7171
-i ES01 `# For now it is ok if docstrings are missing the extended summary` \
7272
-i "pandas.Series.dt PR01" `# Accessors are implemented as classes, but we do not document the Parameters section` \
73-
-i "pandas.MultiIndex.get_level_values SA01" \
7473
-i "pandas.MultiIndex.get_loc_level PR07" \
7574
-i "pandas.MultiIndex.names SA01" \
7675
-i "pandas.MultiIndex.reorder_levels RT03,SA01" \

pandas/core/indexes/multi.py

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1783,6 +1783,16 @@ def get_level_values(self, level) -> Index: # type: ignore[override]
17831783
Return vector of label values for requested level.
17841784
17851785
Length of returned vector is equal to the length of the index.
1786+
The `get_level_values` method is a crucial utility for extracting
1787+
specific level values from a `MultiIndex`. This function is particularly
1788+
useful when working with multi-level data, allowing you to isolate
1789+
and manipulate individual levels without having to deal with the
1790+
complexity of the entire `MultiIndex` structure. It seamlessly handles
1791+
both integer and string-based level access, providing flexibility in
1792+
how you can interact with the data. Additionally, this method ensures
1793+
that the returned `Index` maintains the integrity of the original data,
1794+
even when missing values are present, by appropriately casting the
1795+
result to a suitable data type.
17861796
17871797
Parameters
17881798
----------
@@ -1796,6 +1806,13 @@ def get_level_values(self, level) -> Index: # type: ignore[override]
17961806
Values is a level of this MultiIndex converted to
17971807
a single :class:`Index` (or subclass thereof).
17981808
1809+
See Also
1810+
--------
1811+
MultiIndex : A multi-level, or hierarchical, index object for pandas objects.
1812+
Index : Immutable sequence used for indexing and alignment.
1813+
MultiIndex.remove_unused_levels : Create new MultiIndex from current that
1814+
removes unused levels.
1815+
17991816
Notes
18001817
-----
18011818
If the level contains missing values, the result may be casted to

0 commit comments

Comments
 (0)