Skip to content

Dropping top level in multiindex independently of key #41416

Closed
@didacrarbones

Description

@didacrarbones

I am developing some code that derives various pandas classes, and I have stumbled what seems to me like a bug. I do not have too much experience with pandas, so pardon me if this is obviously wrong.

In function maybe_droplevels from the multiindex file, lines 3878 and 3884 disregard the content of key and directly drop the top-most level. It has been like that for at least some years. I am not sure if this was by design in the beginning, to avoid issues, but after a brief look I cannot find the reason why it is would not possible to drop only the level where key is.

My code derives MultiIndex, and when I return a slice that shrinks the DataFrame size, line 3463 wants to shrink the size of the index too.

Metadata

Metadata

Assignees

No one assigned

    Labels

    MultiIndexNeeds InfoClarification about behavior needed to assess issue

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions