{"record":{"id":"1e0439088381c5ff","repo":"pandas-dev/pandas","slug":"invalid-option-for-closed-closed","errorCode":null,"errorMessage":"invalid option for 'closed': {closed}","messagePattern":"invalid option for 'closed': (.+?)","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"pandas/core/arrays/interval.py","lineNumber":1483,"sourceCode":"        --------\n        IntervalArray.closed : Returns inclusive side of the Interval.\n        arrays.IntervalArray.closed : Returns inclusive side of the IntervalArray.\n\n        Examples\n        --------\n        >>> index = pd.arrays.IntervalArray.from_breaks(range(4))\n        >>> index\n        <IntervalArray>\n        [(0, 1], (1, 2], (2, 3]]\n        Length: 3, dtype: interval[int64, right]\n        >>> index.set_closed(\"both\")\n        <IntervalArray>\n        [[0, 1], [1, 2], [2, 3]]\n        Length: 3, dtype: interval[int64, both]\n        \"\"\"\n        if closed not in VALID_CLOSED:\n            msg = f\"invalid option for 'closed': {closed}\"\n            raise ValueError(msg)\n\n        left, right = self._left, self._right\n        dtype = IntervalDtype(left.dtype, closed=closed)\n        return self._simple_new(left, right, dtype=dtype)\n\n    @property\n    def is_non_overlapping_monotonic(self) -> bool:\n        \"\"\"\n        Return a boolean whether the IntervalArray/IntervalIndex\\\n        is non-overlapping and monotonic.\n\n        Non-overlapping means (no Intervals share points), and monotonic means\n        either monotonic increasing or monotonic decreasing.\n\n        See Also\n        --------\n        overlaps : Check if two IntervalIndex objects overlap.\n","sourceCodeStart":1465,"sourceCodeEnd":1501,"githubUrl":"https://github.com/pandas-dev/pandas/blob/3b7651241d4da534b3559b60ef128e1c34f54116/pandas/core/arrays/interval.py#L1465-L1501","documentation":"Raised by IntervalArray.set_closed when 'closed' is not one of VALID_CLOSED = {'left', 'right', 'both', 'neither'}. The closed attribute must be a recognized value.","triggerScenarios":"arr.set_closed('both-sided'); arr.set_closed(None); arr.set_closed('Right') (case/typo); config-driven closed strings.","commonSituations":"Typos; user-derived config strings; case sensitivity; locale issues.","solutions":["Use one of: 'left', 'right', 'both', 'neither'.","Normalize input strings (e.g., .lower()) and validate against the allowed set before calling.","Default closed from the source data instead of accepting arbitrary user input."],"exampleFix":"// before\narr.set_closed('Both')\n// after\narr.set_closed('both')","handlingStrategy":"validation","validationCode":"VALID_CLOSED = {'left', 'right', 'both', 'neither'}\n\ndef safe_set_closed(arr, closed):\n    if closed not in VALID_CLOSED:\n        raise ValueError(f'closed must be one of {VALID_CLOSED}')\n    return arr.set_closed(closed)","typeGuard":"def is_valid_closed(c):\n    return c in {'left', 'right', 'both', 'neither'}","tryCatchPattern":null,"preventionTips":["Validate user/config closed strings against the four allowed values.","Normalize case (.lower()) before calling set_closed.","Default closed from the source data rather than accepting arbitrary input."],"tags":["interval-array","set-closed","validation"],"backgroundTag":null,"analyzedSha":"3b7651241d4da534b3559b60ef128e1c34f54116","analyzedAt":"2026-08-11T22:10:44.015Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}