Skip to content

BUG: Fix DatetimeIndex timezone preservation when joining indexes with same timezone but different units #61234

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

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

myenugula
Copy link
Contributor

@myenugula
Copy link
Contributor Author

Hi @rhshadrach, could you please check this one out?

Copy link
Member

@rhshadrach rhshadrach left a comment

Choose a reason for hiding this comment

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

@mroeschke - this change will make it so the unit comes out to be the minimum between the two time inputs. Does that look like the correct behavior to you?

Comment on lines +215 to +219
# Test union preserves timezone when units differ
result = idx1.union(idx2)
expected = date_range("2000-01-01", periods=3, tz=tz).as_unit("ns")
tm.assert_index_equal(result, expected)
assert result.tz == idx1.tz # Original timezone is preserved
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 break these up into separate tests or parametrize them.

@mroeschke mroeschke requested a review from jbrockmendel April 16, 2025 16:09
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.

BUG: Timezone upon DatetimeIndex union is changed to UTC
2 participants