-
-
Notifications
You must be signed in to change notification settings - Fork 18.5k
BUG: IntervalArray.__setitem__ creates copies incorrectly #27147
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
I originally thought #32782 would fix this, but it doesn't get all the way across the finish line. |
This from the explicit copies at pandas/pandas/core/arrays/interval.py Lines 556 to 564 in 72aed3e
To check that, this diff gets the original example working. diff --git a/pandas/core/arrays/interval.py b/pandas/core/arrays/interval.py
index c861d25afd..344538d1a2 100644
--- a/pandas/core/arrays/interval.py
+++ b/pandas/core/arrays/interval.py
@@ -555,11 +555,13 @@ class IntervalArray(IntervalMixin, ExtensionArray):
# Need to ensure that left and right are updated atomically, so we're
# forced to copy, update the copy, and swap in the new values.
- left = self.left.copy(deep=True)
+ # left = self.left.copy(deep=True)
+ left = self.left
left._values[key] = value_left
self._left = left
- right = self.right.copy(deep=True)
+ # right = self.right.copy(deep=True)
+ right = self.right
right._values[key] = value_right
self._right = right However, as the comment indicates I don't think we can just do that. Perhaps the flow should be
(the fact that we're manipulating |
That looks right to me. Ideally we could do this without making copies, but this is a strict improvement over the status quo. |
closed by #36310 |
The text was updated successfully, but these errors were encountered: