Skip to content

BUG: Timezone upon DatetimeIndex union is changed to UTC #60080

Open
@alippai

Description

@alippai

Pandas version checks

  • I have checked that this issue has not already been reported.

  • I have confirmed this bug exists on the latest version of pandas.

  • I have confirmed this bug exists on the main branch of pandas.

Reproducible Example

import pandas as pd

i1 = pd.DatetimeIndex(['2020-01-01 10:00:00+05:00']).astype('datetime64[us, UTC+05:00]')
i2 = pd.DatetimeIndex(['2020-01-01 10:00:00+05:00']).astype('datetime64[ns, UTC+05:00]')
i1.union(i2) # returns DatetimeIndex(['2020-01-01 05:00:00+00:00'], dtype='datetime64[ns, UTC]', freq=None)

Issue Description

@lukemanley @mroeschke looks like test case from #55238 could be extended to different timezones, currently if taking the union of two DatetimeIndex with the same timezone, but different unit, then it results in an UTC timezone.

Expected Behavior

The result should be the higher resolution unit and the original timezone

Installed Versions

python : 3.10.14 pandas : 2.2.2

Metadata

Metadata

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions