From 09add600c3b2c463698472f2d4a9c18b8e5ca661 Mon Sep 17 00:00:00 2001 From: tuhinsharma121 Date: Sat, 11 May 2024 18:54:10 +0530 Subject: [PATCH 1/2] DOC: add GL08 for pandas.IntervalIndex.length --- pandas/core/indexes/interval.py | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/pandas/core/indexes/interval.py b/pandas/core/indexes/interval.py index 98c8739039d69..4b9d055382c48 100644 --- a/pandas/core/indexes/interval.py +++ b/pandas/core/indexes/interval.py @@ -924,6 +924,34 @@ def mid(self) -> Index: @property def length(self) -> Index: + """ + Calculate the length of each interval in the IntervalIndex. + + This method returns a new Index containing the lengths of each interval + in the IntervalIndex. The length of an interval is defined as the difference + between its end and its start. + + Returns + ------- + Index + An Index containing the lengths of each interval. + + See Also + -------- + Interval.length : Return the length of the Interval. + + Examples + -------- + >>> intervals = pd.IntervalIndex.from_arrays( + ... [1, 2, 3], [4, 5, 6], closed="right" + ... ) + >>> intervals.length + Index([3, 3, 3], dtype='int64') + + >>> intervals = pd.IntervalIndex.from_tuples([(1, 5), (6, 10), (11, 15)]) + >>> intervals.length + Index([4, 4, 4], dtype='int64') + """ return Index(self._data.length, copy=False) # -------------------------------------------------------------------- From 33a3cac7b206fa567961b508c5eaf9dc489eafb0 Mon Sep 17 00:00:00 2001 From: tuhinsharma121 Date: Sat, 11 May 2024 18:54:28 +0530 Subject: [PATCH 2/2] DOC: remove GL08 for pandas.IntervalIndex.length --- ci/code_checks.sh | 1 - 1 file changed, 1 deletion(-) diff --git a/ci/code_checks.sh b/ci/code_checks.sh index b3d6c5156c54d..931633c842ad0 100755 --- a/ci/code_checks.sh +++ b/ci/code_checks.sh @@ -79,7 +79,6 @@ if [[ -z "$CHECK" || "$CHECK" == "docstrings" ]]; then -i "pandas.Index PR07" \ -i "pandas.IntervalIndex.is_non_overlapping_monotonic SA01" \ -i "pandas.IntervalIndex.left GL08" \ - -i "pandas.IntervalIndex.length GL08" \ -i "pandas.IntervalIndex.set_closed RT03,SA01" \ -i "pandas.IntervalIndex.to_tuples RT03,SA01" \ -i "pandas.MultiIndex PR01" \