Skip to content

Commit

Permalink
DOC: fix ES01,RT03,SA01 for pandas.MultiIndex.remove_unused_levels (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
tuhinsharma121 authored Jul 31, 2024
1 parent 6fdafda commit 4c39c08
Show file tree
Hide file tree
Showing 2 changed files with 13 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 @@ -73,7 +73,6 @@ if [[ -z "$CHECK" || "$CHECK" == "docstrings" ]]; then
-i "pandas.MultiIndex.get_level_values SA01" \
-i "pandas.MultiIndex.get_loc_level PR07" \
-i "pandas.MultiIndex.names SA01" \
-i "pandas.MultiIndex.remove_unused_levels RT03,SA01" \
-i "pandas.MultiIndex.reorder_levels RT03,SA01" \
-i "pandas.MultiIndex.sortlevel PR07,SA01" \
-i "pandas.MultiIndex.to_frame RT03" \
Expand Down
13 changes: 13 additions & 0 deletions pandas/core/indexes/multi.py
Original file line number Diff line number Diff line change
Expand Up @@ -2091,9 +2091,22 @@ def remove_unused_levels(self) -> MultiIndex:
appearance, meaning the same .values and ordering. It will
also be .equals() to the original.
The `remove_unused_levels` method is useful in cases where you have a
MultiIndex with hierarchical levels, but some of these levels are no
longer needed due to filtering or subsetting operations. By removing
the unused levels, the resulting MultiIndex becomes more compact and
efficient, which can improve performance in subsequent operations.
Returns
-------
MultiIndex
A new MultiIndex with unused levels removed.
See Also
--------
MultiIndex.droplevel : Remove specified levels from a MultiIndex.
MultiIndex.reorder_levels : Rearrange levels of a MultiIndex.
MultiIndex.set_levels : Set new levels on a MultiIndex.
Examples
--------
Expand Down

0 comments on commit 4c39c08

Please sign in to comment.