Skip to content

Conversation

skalwaghe-56
Copy link

@skalwaghe-56 skalwaghe-56 commented Sep 2, 2025


This PR adds a regression test for a bug where inserting and then deleting
a column in a DataFrame with two-level MultiIndex columns (with a Timestamp
level) used to raise a RecursionError.

The bug is already fixed on main, but this test makes sure it won’t come back.

Test location: pandas/tests/frame/indexing/test_insert.py
Test method: TestDataFrameInsert.test_insert_delete_mixed_multiindex_columns

@skalwaghe-56
Copy link
Author

Hi, I've opened a PR which adds a regression test for this issue: #56853.

@skalwaghe-56
Copy link
Author

All checks have passed, I request one of the members to review the changes and kindly merge this PR. Thanks :)

Copy link
Member

@rhshadrach rhshadrach left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the PR!

Comment on lines +101 to +104
from pandas import (
DataFrame,
Timestamp,
)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you move this to the top of the file

Comment on lines +111 to +113
# Verify MultiIndex and that 'B' appears in the top level
assert isinstance(df.columns, MultiIndex)
assert "B" in df.columns.get_level_values(0)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you instead check the entire state of df. Also the comment repeats the code and can be removed.

expected = ...
tm.assert_frame_equal(df, expected)

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for your reply! I will surely implement these changes after school. Thanks!

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: Insert then delete column into MultiIndex with timestamps leads to RecursionError
2 participants