Skip to content

FIX-#5635: Correct reset_index column collision check for custom index names - #7716

Open
puja-hansitha wants to merge 1 commit into
modin-project:mainfrom
puja-hansitha:fix-reset-index-custom-name
Open

puja-hansitha wants to merge 1 commit into
modin-project:mainfrom
puja-hansitha:fix-reset-index-custom-name

Conversation

@puja-hansitha

@puja-hansitha puja-hansitha commented Oct 11, 2026 •

Copy link
Copy Markdown

What do these changes do?

Description

In BasePandasDataset.reset_index, an eager check assumed that having "level_0" and "index" in columns would always collide upon reset, regardless of whether the index had a custom name. This caused:

  1. reset_index to raise ValueError: cannot insert level_0, already exists even when the index had a custom name that would not collide (resolves BUG: reset_index raises ValueError ("cannot insert level_0, already exists") even if the index has a custom name #5635).
  2. Failure to detect collisions when a custom index name matched an existing column label (which would silently create duplicate columns instead of raising ValueError).
  3. Incomplete support for MultiIndex level collisions and failure to respect allow_duplicates=True.

This PR updates BasePandasDataset.reset_index to determine the exact inserted column names and validate for collisions in reverse order of level insertion, fully matching pandas behavior.

…r custom index names

Signed-off-by: Puja <katepallipujahansitha@gmail.com>

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

BUG: reset_index raises ValueError ("cannot insert level_0, already exists") even if the index has a custom name

1 participant