From cd7fc5f30dcfb5c9ccbbf5b22c0beaf84b5f3969 Mon Sep 17 00:00:00 2001 From: tuhinsharma121 Date: Tue, 7 May 2024 23:09:52 +0530 Subject: [PATCH 1/2] DOC: add RT03 for interval contains method --- pandas/core/arrays/interval.py | 38 +++++++++++++++++++++++++--------- 1 file changed, 28 insertions(+), 10 deletions(-) diff --git a/pandas/core/arrays/interval.py b/pandas/core/arrays/interval.py index b93d93fe05bc5..90138baac324a 100644 --- a/pandas/core/arrays/interval.py +++ b/pandas/core/arrays/interval.py @@ -1753,22 +1753,40 @@ def repeat( """ ) - @Appender( - _interval_shared_docs["contains"] - % { - "klass": "IntervalArray", - "examples": textwrap.dedent( - """\ + def contains(self, other): + """ + Check elementwise if the Intervals contain the value. + + Return a boolean mask whether the value is contained in the Intervals + of the IntervalArray. + + Parameters + ---------- + other : scalar + The value to check whether it is contained in the Intervals. + + Returns + ------- + boolean array + A boolean mask whether the value is contained in the Intervals. + + See Also + -------- + Interval.contains : Check whether Interval object contains value. + IntervalArray.overlaps : Check if an Interval overlaps the values in the + IntervalArray. + + Examples + -------- >>> intervals = pd.arrays.IntervalArray.from_tuples([(0, 1), (1, 3), (2, 4)]) >>> intervals [(0, 1], (1, 3], (2, 4]] Length: 3, dtype: interval[int64, right] + + >>> intervals.contains(0.5) + array([ True, False, False]) """ - ), - } - ) - def contains(self, other): if isinstance(other, Interval): raise NotImplementedError("contains not implemented for two intervals") From cbef2a0532faa15a2caec662905e10bc2c2275d0 Mon Sep 17 00:00:00 2001 From: tuhinsharma121 Date: Tue, 7 May 2024 23:10:11 +0530 Subject: [PATCH 2/2] DOC: remove RT03 for interval contains method --- ci/code_checks.sh | 2 -- 1 file changed, 2 deletions(-) diff --git a/ci/code_checks.sh b/ci/code_checks.sh index 64bcde23ce34d..f4ab206212d92 100755 --- a/ci/code_checks.sh +++ b/ci/code_checks.sh @@ -78,7 +78,6 @@ if [[ -z "$CHECK" || "$CHECK" == "docstrings" ]]; then -i "pandas.Grouper PR02" \ -i "pandas.Index PR07" \ -i "pandas.Interval PR02" \ - -i "pandas.IntervalIndex.contains RT03" \ -i "pandas.IntervalIndex.get_loc PR07,RT03,SA01" \ -i "pandas.IntervalIndex.is_non_overlapping_monotonic SA01" \ -i "pandas.IntervalIndex.left GL08" \ @@ -415,7 +414,6 @@ if [[ -z "$CHECK" || "$CHECK" == "docstrings" ]]; then -i "pandas.arrays.DatetimeArray SA01" \ -i "pandas.arrays.FloatingArray SA01" \ -i "pandas.arrays.IntegerArray SA01" \ - -i "pandas.arrays.IntervalArray.contains RT03" \ -i "pandas.arrays.IntervalArray.is_non_overlapping_monotonic SA01" \ -i "pandas.arrays.IntervalArray.left SA01" \ -i "pandas.arrays.IntervalArray.length SA01" \