Skip to content

Commit

Permalink
DOC: fix SA01 for pandas.MultiIndex.get_level_values (#59400)
Browse files Browse the repository at this point in the history
Co-authored-by: Matthew Roeschke <10647082+mroeschke@users.noreply.github.com>
  • Loading branch information
tuhinsharma121 and mroeschke authored Aug 5, 2024
1 parent 81a12dd commit 66c5b9a
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 1 deletion.
1 change: 0 additions & 1 deletion ci/code_checks.sh
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,6 @@ if [[ -z "$CHECK" || "$CHECK" == "docstrings" ]]; then
--format=actions \
-i ES01 `# For now it is ok if docstrings are missing the extended summary` \
-i "pandas.Series.dt PR01" `# Accessors are implemented as classes, but we do not document the Parameters section` \
-i "pandas.MultiIndex.get_level_values SA01" \
-i "pandas.MultiIndex.get_loc_level PR07" \
-i "pandas.MultiIndex.names SA01" \
-i "pandas.MultiIndex.reorder_levels RT03,SA01" \
Expand Down
17 changes: 17 additions & 0 deletions pandas/core/indexes/multi.py
Original file line number Diff line number Diff line change
Expand Up @@ -1783,6 +1783,16 @@ def get_level_values(self, level) -> Index: # type: ignore[override]
Return vector of label values for requested level.
Length of returned vector is equal to the length of the index.
The `get_level_values` method is a crucial utility for extracting
specific level values from a `MultiIndex`. This function is particularly
useful when working with multi-level data, allowing you to isolate
and manipulate individual levels without having to deal with the
complexity of the entire `MultiIndex` structure. It seamlessly handles
both integer and string-based level access, providing flexibility in
how you can interact with the data. Additionally, this method ensures
that the returned `Index` maintains the integrity of the original data,
even when missing values are present, by appropriately casting the
result to a suitable data type.
Parameters
----------
Expand All @@ -1796,6 +1806,13 @@ def get_level_values(self, level) -> Index: # type: ignore[override]
Values is a level of this MultiIndex converted to
a single :class:`Index` (or subclass thereof).
See Also
--------
MultiIndex : A multi-level, or hierarchical, index object for pandas objects.
Index : Immutable sequence used for indexing and alignment.
MultiIndex.remove_unused_levels : Create new MultiIndex from current that
removes unused levels.
Notes
-----
If the level contains missing values, the result may be casted to
Expand Down

0 comments on commit 66c5b9a

Please sign in to comment.