{"record":{"id":"3526585857b74fa1","repo":"pandas-dev/pandas","slug":"cls-name-must-be-called-with-a-collecti","errorCode":null,"errorMessage":"{cls.__name__}(...) must be called with a collection of some kind, {data} was passed","messagePattern":"(.+?)\\(\\.\\.\\.\\) must be called with a collection of some kind, (.+?) was passed","errorType":"exception","errorClass":"TypeError","httpStatus":null,"severity":"error","filePath":"pandas/core/arrays/interval.py","lineNumber":231,"sourceCode":"        dtype: Dtype | None = None,\n        copy: bool = False,\n        verify_integrity: bool = True,\n    ) -> Self:\n        data = extract_array(data, extract_numpy=True)\n\n        if isinstance(data, cls):\n            left: IntervalSide = data._left\n            right: IntervalSide = data._right\n            closed = closed or data.closed\n            dtype = IntervalDtype(left.dtype, closed=closed)\n        else:\n            # don't allow scalars\n            if is_scalar(data):\n                msg = (\n                    f\"{cls.__name__}(...) must be called with a collection \"\n                    f\"of some kind, {data} was passed\"\n                )\n                raise TypeError(msg)\n\n            # might need to convert empty or purely na data\n            data = _maybe_convert_platform_interval(data)\n            left, right, infer_closed = intervals_to_interval_bounds(\n                data, validate_closed=closed is None\n            )\n            if left.dtype == object:\n                left = lib.maybe_convert_objects(left)\n                right = lib.maybe_convert_objects(right)\n            closed = closed or infer_closed\n\n            left, right, dtype = cls._ensure_simple_new_inputs(\n                left,\n                right,\n                closed=closed,\n                copy=copy,\n                dtype=dtype,\n            )","sourceCodeStart":213,"sourceCodeEnd":249,"githubUrl":"https://github.com/pandas-dev/pandas/blob/71959b8cb9b2459c16e14b34f28b178ccfe14735/pandas/core/arrays/interval.py#L213-L249","documentation":"Raised by IntervalArray.__new__/_from_sequence when the data argument is a scalar (a single value) rather than a collection. Intervals arrays need a sequence of intervals or bounds; a scalar has no length/shape to build from. TypeError naming the class and the offending value.","triggerScenarios":"pd.arrays.IntervalArray(pd.Interval(0, 5)); pd.IntervalIndex(0.5); passing a single Interval or number where a list/Series is expected.","commonSituations":"Forgetting to wrap a single value in a list; refactoring that yields a scalar from a previous step; treating a function meant for arrays as a scalar constructor.","solutions":["Wrap the value in a collection: pd.arrays.IntervalArray([pd.Interval(0, 5)]).","For a single interval use pd.Interval directly, not the array constructor.","Verify the upstream expression returns a sequence before passing it in."],"exampleFix":"# before\npd.arrays.IntervalArray(pd.Interval(0, 5))\n# after\npd.arrays.IntervalArray([pd.Interval(0, 5)])","handlingStrategy":"type-guard","validationCode":"def to_interval_array(data):\n    if pd.api.types.is_scalar(data):\n        raise TypeError('IntervalArray requires a collection, wrap the scalar in a list')\n    return pd.arrays.IntervalArray(data)","typeGuard":"def is_collection(x) -> bool:\n    return not pd.api.types.is_scalar(x) and hasattr(x, '__iter__')","tryCatchPattern":null,"preventionTips":["Wrap single intervals in a list.","Use pd.Interval for scalar use cases.","Check is_scalar before array constructors."],"tags":["interval","construction","scalar","pandas"],"analyzedSha":"71959b8cb9b2459c16e14b34f28b178ccfe14735","analyzedAt":"2026-08-07T01:30:20.476Z","schemaVersion":2},"datasetVersion":"2026-08-07T03:17:09.362Z"}