Skip to content

Conversation

@sudam802
Copy link

Fixes GH#63169.

Index.intersection previously returned the original Index instance
when both Index objects were equal and unique:

idx1 = Index([0, 1])
idx2 = Index([0, 1])
result = idx1.intersection(idx2)
result is idx1   # True (incorrect)

This caused identity issues when downstream code expected a new Index.

This PR ensures that a new Index object is always returned when
intersection is computed, even if both indexes are equal.

A new test has been added:

  • test_intersection_returns_new_instance

This confirms:

  • the result contains the correct values
  • the returned Index is not the same object reference.

@sudam802 sudam802 marked this pull request as draft November 23, 2025 19:11
@sudam802 sudam802 marked this pull request as ready for review November 23, 2025 19:12
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.

1 participant