Skip to content
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

ENH: Add is_empty attribute to Interval structures #27219

jschendel opened this issue Jul 3, 2019 · 0 comments


Copy link

commented Jul 3, 2019

An is_empty attribute would be useful, as it is often necessary to special case empty intervals when dealing with Interval methods such as overlaps, contains, etc. (xref #26893)

For a scalar Interval this should return a boolean:

In [2]: pd.Interval(0, 0, closed='neither').is_empty
Out[2]: True

In [3]: pd.Interval(0, 1, closed='neither').is_empty
Out[3]: False

For an IntervalIndex or IntervalArray this should return a boolean ndarray positionally indicating if a given Interval is empty:

In [4]: pd.IntervalIndex.from_tuples([(0, 0), (0, 1)]).is_empty
Out[4]: array([ True, False])
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
None yet
1 participant
You can’t perform that action at this time.