Skip to content

API: Add closed to IntervalDtype #19371

Closed
@jschendel

Description

@jschendel

This was brought up by @shoyer in a different issue, and it makes sense to me

Adding closed to IntervalDtype makes sense to me, as in my mind closed is inherently part of the dtype. Since differing closed makes two IntervalIndex incompatible, I'd expect their dtypes to not be equal, but they currently are, which seems a little strange:

In [2]: ii1 = pd.interval_range(0, 3, closed='left')

In [3]: ii2 = pd.interval_range(0, 3, closed='right')

In [4]: ii1.dtype == ii2.dtype
Out[4]: True

There's also a larger discussion as to if adding closed to IntervalDtype would allow us to remove closed as a parameter to the IntervalIndex constructor. My preference would be to keep the closed parameter for user convenience, similar to how CategoricalIndex accepts categories and ordered parameters despite also accepting CategoricalDtype (though maybe this is just for legacy reasons). Willing to be convinced otherwise though.

xref #19263 (comment) (original comment)
xref #19370 (might be rendered moot)

cc @shoyer

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions