Skip to content

Commit

Permalink
DOC: Add GL08 for pandas.intervalIndex.left (#58687)
Browse files Browse the repository at this point in the history
* DOC: add GL08 for pandas.IntervalIndex.left

mroeschke

* DOC: remove GL08 for pandas.IntervalIndex.left

Co-authored-by: mroeschke

* DOC: fix example for iv_idx.left
  • Loading branch information
tuhinsharma121 committed May 12, 2024
1 parent 9f7b3cc commit 529bcc1
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 1 deletion.
1 change: 0 additions & 1 deletion ci/code_checks.sh
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,6 @@ if [[ -z "$CHECK" || "$CHECK" == "docstrings" ]]; then
-i "pandas.DataFrame.min RT03" \
-i "pandas.DataFrame.plot PR02,SA01" \
-i "pandas.Grouper PR02" \
-i "pandas.IntervalIndex.left GL08" \
-i "pandas.MultiIndex PR01" \
-i "pandas.MultiIndex.append PR07,SA01" \
-i "pandas.MultiIndex.copy PR07,RT03,SA01" \
Expand Down
33 changes: 33 additions & 0 deletions pandas/core/indexes/interval.py
Original file line number Diff line number Diff line change
Expand Up @@ -842,6 +842,39 @@ def _is_comparable_dtype(self, dtype: DtypeObj) -> bool:

@cache_readonly
def left(self) -> Index:
"""
Return left bounds of the intervals in the IntervalIndex.
The left bounds of each interval in the IntervalIndex are
returned as an Index. The datatype of the left bounds is the
same as the datatype of the endpoints of the intervals.
Returns
-------
Index
An Index containing the left bounds of the intervals.
See Also
--------
IntervalIndex.right : Return the right bounds of the intervals
in the IntervalIndex.
IntervalIndex.mid : Return the mid-point of the intervals in
the IntervalIndex.
IntervalIndex.length : Return the length of the intervals in
the IntervalIndex.
Examples
--------
>>> iv_idx = pd.IntervalIndex.from_arrays([1, 2, 3], [4, 5, 6], closed="right")
>>> iv_idx.left
Index([1, 2, 3], dtype='int64')
>>> iv_idx = pd.IntervalIndex.from_tuples(
... [(1, 4), (2, 5), (3, 6)], closed="left"
... )
>>> iv_idx.left
Index([1, 2, 3], dtype='int64')
"""
return Index(self._data.left, copy=False)

@cache_readonly
Expand Down

0 comments on commit 529bcc1

Please sign in to comment.