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

DOC: update docstrings of Interval's attributes #50609

Merged
merged 1 commit into from
Jan 8, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
68 changes: 68 additions & 0 deletions pandas/_libs/interval.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,21 @@ cdef class IntervalMixin:
-------
bool
True if the Interval is closed on the left-side.

See Also
--------
Interval.closed_right : Check if the interval is closed on the right side.
Interval.open_left : Boolean inverse of closed_left.

Examples
--------
>>> iv = pd.Interval(0, 5, closed='left')
>>> iv.closed_left
True

>>> iv = pd.Interval(0, 5, closed='right')
>>> iv.closed_left
False
"""
return self.closed in ("left", "both")

Expand All @@ -72,6 +87,21 @@ cdef class IntervalMixin:
-------
bool
True if the Interval is closed on the left-side.

See Also
--------
Interval.closed_left : Check if the interval is closed on the left side.
Interval.open_right : Boolean inverse of closed_right.

Examples
--------
>>> iv = pd.Interval(0, 5, closed='both')
>>> iv.closed_right
True

>>> iv = pd.Interval(0, 5, closed='left')
>>> iv.closed_right
False
"""
return self.closed in ("right", "both")

Expand All @@ -86,6 +116,21 @@ cdef class IntervalMixin:
-------
bool
True if the Interval is not closed on the left-side.

See Also
--------
Interval.open_right : Check if the interval is open on the right side.
Interval.closed_left : Boolean inverse of open_left.

Examples
--------
>>> iv = pd.Interval(0, 5, closed='neither')
>>> iv.open_left
True

>>> iv = pd.Interval(0, 5, closed='both')
>>> iv.open_left
False
"""
return not self.closed_left

Expand All @@ -100,6 +145,21 @@ cdef class IntervalMixin:
-------
bool
True if the Interval is not closed on the left-side.

See Also
--------
Interval.open_left : Check if the interval is open on the left side.
Interval.closed_right : Boolean inverse of open_right.

Examples
--------
>>> iv = pd.Interval(0, 5, closed='left')
>>> iv.open_right
True

>>> iv = pd.Interval(0, 5)
>>> iv.open_right
False
"""
return not self.closed_right

Expand All @@ -124,6 +184,10 @@ cdef class IntervalMixin:
def length(self):
"""
Return the length of the Interval.

See Also
--------
Interval.is_empty : Indicates if an interval contains no points.
"""
return self.right - self.left

Expand All @@ -140,6 +204,10 @@ cdef class IntervalMixin:
an :class:`~arrays.IntervalArray` or :class:`IntervalIndex` is
empty.

See Also
--------
Interval.length : Return the length of the Interval.

Examples
--------
An :class:`Interval` that contains points is not empty:
Expand Down