Skip to content

Commit eae020c

Browse files
KhemkaranKhemkaran
authored andcommitted
modified unique() function in arrays/interval.py
1 parent 843539c commit eae020c

File tree

1 file changed

+10
-10
lines changed

1 file changed

+10
-10
lines changed

pandas/core/arrays/interval.py

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1990,20 +1990,20 @@ def _from_combined(self, combined: np.ndarray) -> IntervalArray:
19901990
return self._shallow_copy(left=new_left, right=new_right)
19911991

19921992
def unique(self) -> IntervalArray:
1993-
# Using .view("complex128") with negatives causes issues. # GH#61917
1994-
combined = self._combined
1995-
combined = np.ascontiguousarray(combined)
1996-
if combined.dtype == np.object_:
1993+
# No overload variant of "__getitem__" of "ExtensionArray" matches argument
1994+
# type "Tuple[slice, int]"
1995+
if needs_i8_conversion(self._left.dtype):
19971996
nc = unique(
19981997
self._combined.view("complex128")[:, 0] # type: ignore[call-overload]
19991998
)
2000-
nc = nc[:, None]
20011999
else:
2002-
structured = combined.view(
2003-
[("left", combined.dtype), ("right", combined.dtype)]
2004-
)[:, 0]
2005-
unique_structured = unique(structured)
2006-
nc = unique_structured.view(combined.dtype)
2000+
nc = unique(
2001+
# Using .view("complex128") with negatives causes issues.
2002+
# GH#61917
2003+
(np.array(self._combined[:, 0], dtype=complex))
2004+
+ (1j * np.array(self._combined[:, 1], dtype=complex))
2005+
)
2006+
nc = nc[:, None]
20072007
return self._from_combined(nc)
20082008

20092009

0 commit comments

Comments
 (0)