Skip to content

Adding tests for IntervalArray.unique() for DateTimeArrays with time zones #46153

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

Merged
merged 13 commits into from
Feb 26, 2022
Merged
Changes from 12 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions pandas/tests/arrays/interval/test_interval.py
Original file line number Diff line number Diff line change
Expand Up @@ -376,3 +376,18 @@ def test_arrow_table_roundtrip_without_metadata(breaks):
result = table.to_pandas()
assert isinstance(result["a"].dtype, pd.IntervalDtype)
tm.assert_frame_equal(result, df)


def test_tz_unique():
# GH 46128
dti1 = date_range("2016-01-01", periods=3)
ii1 = IntervalIndex.from_breaks(dti1)
ser1 = pd.Series(ii1)
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 either put this in the series tests or test the array method directly. ideally do a tm.assert_foo_equal below, should be easy bc .unique matches self in these cases

Copy link
Contributor Author

Choose a reason for hiding this comment

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

OK, moved to series tests in next commit.

uni1 = ser1.unique()

dti2 = date_range("2016-01-01", periods=3, tz="US/Eastern")
ii2 = IntervalIndex.from_breaks(dti2)
ser2 = pd.Series(ii2)
uni2 = ser2.unique()

assert uni1.dtype != uni2.dtype