Skip to content

BUG: Allow using datetime64[ns, UTC] in IntervalDtype #46999

Closed
@simonjayhawkins

Description

@simonjayhawkins

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

dates = pd.date_range("2022", periods=3, tz="UTC")
print(pd.IntervalIndex.from_arrays(dates[:-1], dates[1:]))
print(
    pd.IntervalIndex.from_arrays(
        ["2022-01-01", "2022-01-02"],
        ["2022-01-02", "2022-01-03"],
        dtype="interval[datetime64[ns, UTC], right]",
    )
)

Issue Description

raises TypeError: data type 'interval[datetime64[ns, UTC], right]' not understood

xref #46666

works for Interval of naive timeseries...

dates = pd.date_range("2022", periods=3)
print(pd.IntervalIndex.from_arrays(dates[:-1], dates[1:]))
print(
    pd.IntervalIndex.from_arrays(
        ["2022-01-01", "2022-01-02"],
        ["2022-01-02", "2022-01-03"],
        dtype="interval[datetime64[ns], right]",
    )
)

Expected Behavior

IntervalIndex([(2022-01-01, 2022-01-02], (2022-01-02, 2022-01-03]], dtype='interval[datetime64[ns, UTC], right]')

Installed Versions

.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions