Skip to content

DOC: fixing GL08 errors for pandas.IntervalIndex.left, pandas.IntervalIndex.mid and pandas.IntervalIndex.length #57580

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

Closed
wants to merge 6 commits into from
Closed
Show file tree
Hide file tree
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
3 changes: 0 additions & 3 deletions ci/code_checks.sh
Original file line number Diff line number Diff line change
Expand Up @@ -148,9 +148,6 @@ if [[ -z "$CHECK" || "$CHECK" == "docstrings" ]]; then
pandas.Index.empty\
pandas.Index.names\
pandas.Index.view\
pandas.IntervalIndex.left\
pandas.IntervalIndex.length\
pandas.IntervalIndex.mid\
pandas.IntervalIndex.right\
pandas.Period.freq\
pandas.Period.ordinal\
Expand Down
58 changes: 58 additions & 0 deletions pandas/core/indexes/interval.py
Original file line number Diff line number Diff line change
Expand Up @@ -827,6 +827,25 @@ def _is_comparable_dtype(self, dtype: DtypeObj) -> bool:

@cache_readonly
def left(self) -> Index:
"""
Return intervals' left value.

Returns
-------
Index

See Also
--------
IntervalIndex : The structure of IntervalIndex.

Examples
--------
>>> pd.interval_range(start=0, end=5)
IntervalIndex([(0, 1], (1, 2], (2, 3], (3, 4], (4, 5]],
dtype='interval[int64, right]')
>>> pd.interval_range(start=0, end=5).left
Index([0, 1, 2, 3, 4], dtype='int64')
"""
return Index(self._data.left, copy=False)

@cache_readonly
Expand All @@ -835,10 +854,49 @@ def right(self) -> Index:

@cache_readonly
def mid(self) -> Index:
"""
Return the midpoint of each interval.

Returns
-------
Index

See Also
--------
IntervalIndex : The structure of IntervalIndex.

Examples
--------
>>> pd.interval_range(start=0, end=10, periods=3)
IntervalIndex([(0.0, 3.3333333333333335], (3.3333333333333335,
6.666666666666667], (6.666666666666667, 10.0]],
dtype='interval[float64, right]')
>>> pd.interval_range(start=0, end=10, periods=3).mid
Index([1.6666666666666667, 5.0, 8.333333333333334], dtype='float64')
"""
return Index(self._data.mid, copy=False)

@property
def length(self) -> Index:
"""
Return the intervals' length.

Returns
-------
Index

See Also
--------
IntervalIndex : The structure of IntervalIndex.

Examples
--------
>>> pd.interval_range(start=0, end=5)
IntervalIndex([(0, 1], (1, 2], (2, 3], (3, 4], (4, 5]],
dtype='interval[int64, right]')
>>> pd.interval_range(start=0, end=5).length
Index([1, 1, 1, 1, 1], dtype='int64')
"""
return Index(self._data.length, copy=False)

# --------------------------------------------------------------------
Expand Down