diff --git a/ci/code_checks.sh b/ci/code_checks.sh index 13585cbe5e857..61493170f811b 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.IntervalIndex.left GL08" \ - -i "pandas.IntervalIndex.set_closed RT03,SA01" \ -i "pandas.MultiIndex PR01" \ -i "pandas.MultiIndex.append PR07,SA01" \ -i "pandas.MultiIndex.copy PR07,RT03,SA01" \ @@ -396,7 +395,6 @@ if [[ -z "$CHECK" || "$CHECK" == "docstrings" ]]; then -i "pandas.arrays.IntervalArray.length SA01" \ -i "pandas.arrays.IntervalArray.mid SA01" \ -i "pandas.arrays.IntervalArray.right SA01" \ - -i "pandas.arrays.IntervalArray.set_closed RT03,SA01" \ -i "pandas.arrays.NumpyExtensionArray SA01" \ -i "pandas.arrays.SparseArray PR07,SA01" \ -i "pandas.arrays.TimedeltaArray PR07,SA01" \ diff --git a/pandas/core/arrays/interval.py b/pandas/core/arrays/interval.py index ac5e1c049f10a..2e1ea7236e5c4 100644 --- a/pandas/core/arrays/interval.py +++ b/pandas/core/arrays/interval.py @@ -1436,12 +1436,26 @@ def closed(self) -> IntervalClosedType: """ ) - @Appender( - _interval_shared_docs["set_closed"] - % { - "klass": "IntervalArray", - "examples": textwrap.dedent( - """\ + def set_closed(self, closed: IntervalClosedType) -> Self: + """ + Return an identical IntervalArray closed on the specified side. + + Parameters + ---------- + closed : {'left', 'right', 'both', 'neither'} + Whether the intervals are closed on the left-side, right-side, both + or neither. + + Returns + ------- + IntervalArray + A new IntervalArray with the specified side closures. + + See Also + -------- + IntervalArray.closed : Returns inclusive side of the Interval. + arrays.IntervalArray.closed : Returns inclusive side of the IntervalArray. + Examples -------- >>> index = pd.arrays.IntervalArray.from_breaks(range(4)) @@ -1449,15 +1463,11 @@ def closed(self) -> IntervalClosedType: [(0, 1], (1, 2], (2, 3]] Length: 3, dtype: interval[int64, right] - >>> index.set_closed('both') + >>> index.set_closed("both") [[0, 1], [1, 2], [2, 3]] Length: 3, dtype: interval[int64, both] """ - ), - } - ) - def set_closed(self, closed: IntervalClosedType) -> Self: if closed not in VALID_CLOSED: msg = f"invalid option for 'closed': {closed}" raise ValueError(msg)