Skip to content

Commit c2188de

Browse files
authored
Adding tests for IntervalArray.unique() for DateTimeArrays with time zones (#46153)
1 parent 19aa5ab commit c2188de

File tree

1 file changed

+18
-0
lines changed

1 file changed

+18
-0
lines changed

pandas/tests/series/methods/test_unique.py

+18
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,9 @@
22

33
from pandas import (
44
Categorical,
5+
IntervalIndex,
56
Series,
7+
date_range,
68
)
79
import pandas._testing as tm
810

@@ -56,3 +58,19 @@ def test_unique_categorical(self):
5658
ser = Series(cat)
5759
result = ser.unique()
5860
tm.assert_categorical_equal(result, cat)
61+
62+
def test_tz_unique(self):
63+
# GH 46128
64+
dti1 = date_range("2016-01-01", periods=3)
65+
ii1 = IntervalIndex.from_breaks(dti1)
66+
ser1 = Series(ii1)
67+
uni1 = ser1.unique()
68+
tm.assert_interval_array_equal(ser1.array, uni1)
69+
70+
dti2 = date_range("2016-01-01", periods=3, tz="US/Eastern")
71+
ii2 = IntervalIndex.from_breaks(dti2)
72+
ser2 = Series(ii2)
73+
uni2 = ser2.unique()
74+
tm.assert_interval_array_equal(ser2.array, uni2)
75+
76+
assert uni1.dtype != uni2.dtype

0 commit comments

Comments
 (0)