Skip to content

BUG: interpreting dt64 as utc in array_to_datetime/infer_to_datetimelike #49291

@jbrockmendel

Description

@jbrockmendel
values = [pd.Timestamp(0, tz="UTC"), np.datetime64(1, "D").astype("M8[ns]")]

>>> pd.DatetimeIndex(values, tz="US/Pacific")[1:]
DatetimeIndex(['1970-01-01 16:00:00-08:00'], dtype='datetime64[ns, US/Pacific]', freq=None)

>>> pd.DatetimeIndex(values[1:], tz="US/Pacific")
DatetimeIndex(['1970-01-02 00:00:00-08:00'], dtype='datetime64[ns, US/Pacific]', freq=None)

In array_to_datetime if we see a dt64 object and a tz-aware datetime, we treat the dt64 as a UTC time. But if we have dt64 objects and are passed a timezone, we treat them as wall times. I'd expect the two DTIs above to match.

Metadata

Metadata

Assignees

Labels

API - ConsistencyInternal Consistency of API/BehaviorBugConstructorsSeries/DataFrame/Index/pd.array ConstructorsDatetimeDatetime data dtype

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions