{"record":{"id":"99cbf9a95bdec9e4","repo":"pandas-dev/pandas","slug":"value-should-be-a-compatible-interval-type-got","errorCode":null,"errorMessage":"'value' should be a compatible interval type, got {type(value)} instead.","messagePattern":"'value' should be a compatible interval type, got (.+?) instead\\.","errorType":"validation","errorClass":"TypeError","httpStatus":null,"severity":"error","filePath":"pandas/core/arrays/interval.py","lineNumber":1169,"sourceCode":"    def _validate_listlike(self, value):\n        # list-like of intervals\n        try:\n            array = IntervalArray(value)\n            self._check_closed_matches(array, name=\"value\")\n            value_left, value_right = array.left, array.right\n        except TypeError as err:\n            # wrong type: not interval or NA\n            msg = f\"'value' should be an interval type, got {type(value)} instead.\"\n            raise TypeError(msg) from err\n\n        try:\n            self.left._validate_fill_value(value_left)\n        except (LossySetitemError, TypeError) as err:\n            msg = (\n                \"'value' should be a compatible interval type, \"\n                f\"got {type(value)} instead.\"\n            )\n            raise TypeError(msg) from err\n\n        return value_left, value_right\n\n    def _validate_scalar(self, value):\n        if isinstance(value, Interval):\n            self._check_closed_matches(value, name=\"value\")\n            left, right = value.left, value.right\n            self.left._validate_fill_value(left)\n            self.left._validate_fill_value(right)\n        elif is_valid_na_for_dtype(value, self.left.dtype):\n            # GH#18295\n            left = right = self.left._na_value\n        else:\n            raise TypeError(\n                \"can only insert Interval objects and NA into an IntervalArray\"\n            )\n        return left, right\n","sourceCodeStart":1151,"sourceCodeEnd":1187,"githubUrl":"https://github.com/pandas-dev/pandas/blob/3b7651241d4da534b3559b60ef128e1c34f54116/pandas/core/arrays/interval.py#L1151-L1187","documentation":"Raised in IntervalArray._validate_listlike after IntervalArray(value) succeeds, when validating the left endpoint values against the array's subtype fails with LossySetitemError or TypeError. The values are interval-shaped but their endpoints cannot be stored losslessly in this array's subtype (e.g., float intervals into an integer-backed array).","triggerScenarios":"Setting [pd.Interval(1.5, 2.5)] into an int-backed IntervalArray; assigning intervals whose endpoints overflow or do not fit the subtype.","commonSituations":"Mixed-precision interval data; assigning results of float computations to integer interval arrays.","solutions":["Cast the target array to a wider/float subtype first: arr.astype('interval[float64]').","Clean or round endpoint values so they fit the subtype.","Construct a fresh IntervalArray with the appropriate subtype."],"exampleFix":"// before\nint_arr[0] = [pd.Interval(1.5, 2.5)]\n// after\narr = int_arr.astype('interval[float64]')\narr[0] = [pd.Interval(1.5, 2.5)]","handlingStrategy":"validation","validationCode":"def endpoints_fit(arr, value_arr):\n    arr.left._validate_fill_value(value_arr.left)\n    arr.left._validate_fill_value(value_arr.right)\n    return True","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Match the subtype of source and target interval arrays before assignment.","Use float subtypes when bounds may be fractional.","Validate endpoint fill values via _validate_fill_value before setitem."],"tags":["interval-array","setitem","subtype","lossy"],"backgroundTag":null,"analyzedSha":"3b7651241d4da534b3559b60ef128e1c34f54116","analyzedAt":"2026-08-11T22:10:44.015Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}