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

Conversation

abonte
Copy link
Contributor

@abonte abonte commented Jan 6, 2023

Added See Also and/or Examples sections in the docstrings of Interval's attributes:

closed_left, output from `validate_docstrings.py`

################################################################################
################### Docstring (pandas.Interval.closed_left)  ###################
################################################################################

Check if the interval is closed on the left side.

For the meaning of `closed` and `open` see :class:`~pandas.Interval`.

Returns
-------
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

################################################################################
################################## Validation ##################################
################################################################################

Docstring for "pandas.Interval.closed_left" correct. :)

closed_right, output from `validate_docstrings.py`

################################################################################
################### Docstring (pandas.Interval.closed_right) ###################
################################################################################

Check if the interval is closed on the right side.

For the meaning of `closed` and `open` see :class:`~pandas.Interval`.

Returns
-------
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

################################################################################
################################## Validation ##################################
################################################################################

Docstring for "pandas.Interval.closed_right" correct. :)

open_left, output from `validate_docstrings.py`

################################################################################
#################### Docstring (pandas.Interval.open_left)  ####################
################################################################################

Check if the interval is open on the left side.

For the meaning of `closed` and `open` see :class:`~pandas.Interval`.

Returns
-------
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

################################################################################
################################## Validation ##################################
################################################################################

Docstring for "pandas.Interval.open_left" correct. :)

open_right, output from `validate_docstrings.py`

################################################################################
#################### Docstring (pandas.Interval.open_right) ####################
################################################################################

Check if the interval is open on the right side.

For the meaning of `closed` and `open` see :class:`~pandas.Interval`.

Returns
-------
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

################################################################################
################################## Validation ##################################
################################################################################

Docstring for "pandas.Interval.open_right" correct. :)

length, output from `validate_docstrings.py`

################################################################################
###################### Docstring (pandas.Interval.length) ######################
################################################################################

Return the length of the Interval.

See Also
--------
Interval.is_empty : Indicates if an interval contains no points.

################################################################################
################################## Validation ##################################
################################################################################

2 Errors found:
        No extended summary found
        No examples section found
</p>
is_empty, output from `validate_docstrings.py`

################################################################################
##################### Docstring (pandas.Interval.is_empty) #####################
################################################################################

Indicates if an interval is empty, meaning it contains no points.

Returns
-------
bool or ndarray
    A boolean indicating if a scalar :class:`Interval` is empty, or a
    boolean ``ndarray`` positionally indicating if an ``Interval`` in
    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:

>>> pd.Interval(0, 1, closed='right').is_empty
False

An ``Interval`` that does not contain any points is empty:

>>> pd.Interval(0, 0, closed='right').is_empty
True
>>> pd.Interval(0, 0, closed='left').is_empty
True
>>> pd.Interval(0, 0, closed='neither').is_empty
True

An ``Interval`` that contains a single point is not empty:

>>> pd.Interval(0, 0, closed='both').is_empty
False

An :class:`~arrays.IntervalArray` or :class:`IntervalIndex` returns a
boolean ``ndarray`` positionally indicating if an ``Interval`` is
empty:

>>> ivs = [pd.Interval(0, 0, closed='neither'),
...        pd.Interval(1, 2, closed='neither')]
>>> pd.arrays.IntervalArray(ivs).is_empty
array([ True, False])

Missing values are not considered empty:

>>> ivs = [pd.Interval(0, 0, closed='neither'), np.nan]
>>> pd.IntervalIndex(ivs).is_empty
array([ True, False])

################################################################################
################################## Validation ##################################
################################################################################

1 Errors found:
        No extended summary found

@gfyoung gfyoung added Docs Interval Interval data type labels Jan 8, 2023
Copy link
Member

@gfyoung gfyoung left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

cc @phofl since you reviewed one of @abonte other doc PRs

@phofl phofl added this to the 2.0 milestone Jan 8, 2023
@phofl phofl merged commit 059b2c1 into pandas-dev:main Jan 8, 2023
@phofl
Copy link
Member

phofl commented Jan 8, 2023

thx @abonte

@abonte abonte deleted the update-docstrings branch January 8, 2023 21:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Docs Interval Interval data type
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants