diff --git a/ci/code_checks.sh b/ci/code_checks.sh index 9012dc6559a13..1b4121d14f1fc 100755 --- a/ci/code_checks.sh +++ b/ci/code_checks.sh @@ -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.reorder_levels RT03,SA01" \ -i "pandas.NA SA01" \ -i "pandas.NaT SA01" \ -i "pandas.Period.freq GL08" \ diff --git a/pandas/core/indexes/multi.py b/pandas/core/indexes/multi.py index 500a5ad62fddc..878170c8377dc 100644 --- a/pandas/core/indexes/multi.py +++ b/pandas/core/indexes/multi.py @@ -2604,6 +2604,13 @@ def reorder_levels(self, order) -> MultiIndex: """ Rearrange levels using input order. May not drop or duplicate levels. + `reorder_levels` is useful when you need to change the order of levels in + a MultiIndex, such as when reordering levels for hierarchical indexing. It + maintains the integrity of the MultiIndex, ensuring that all existing levels + are present and no levels are duplicated. This method is helpful for aligning + the index structure with other data structures or for optimizing the order + for specific data operations. + Parameters ---------- order : list of int or list of str @@ -2613,6 +2620,13 @@ def reorder_levels(self, order) -> MultiIndex: Returns ------- MultiIndex + A new MultiIndex with levels rearranged according to the specified order. + + See Also + -------- + MultiIndex.swaplevel : Swap two levels of the MultiIndex. + MultiIndex.set_names : Set names for the MultiIndex levels. + DataFrame.reorder_levels : Reorder levels in a DataFrame with a MultiIndex. Examples --------