Skip to content

DOC: MultiIndex.swaplevel default argument values could use an explanation #62768

@Dr-Irv

Description

@Dr-Irv

Pandas version checks

  • I have checked that the issue still exists on the latest versions of the docs on main here

Location of the documentation

https://pandas.pydata.org/docs/reference/api/pandas.MultiIndex.swaplevel.html#pandas.MultiIndex.swaplevel

Documentation problem

The default values for swaplevel() are defined as def swaplevel(self, i=-2, j=-1). Level numbers should start at 0. What the default does is refer to the last 2 levels.

Suggested fix for documentation

I think it would be worthwhile to indicate that negative values are referring to the position of the level relative to the end of the levels of the MultiIndex

Or add something that says that the default swaps the last 2 levels of the MultiIndex

Metadata

Metadata

Assignees

No one assigned

    Labels

    DocsNeeds TriageIssue that has not been reviewed by a pandas team member

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions