{"record":{"id":"c5f2e0d1df1bb6e7","repo":"pandas-dev/pandas","slug":"this-classmethod-must-be-defined-in-the-concrete-c","errorCode":null,"errorMessage":"This classmethod must be defined in the concrete class {name}","messagePattern":"This classmethod must be defined in the concrete class (.+?)","errorType":"exception","errorClass":"AbstractMethodError","httpStatus":null,"severity":"error","filePath":"pandas/core/arrays/base.py","lineNumber":334,"sourceCode":"        Returns\n        -------\n        ExtensionArray\n\n        See Also\n        --------\n        api.extensions.ExtensionArray._from_sequence_of_strings : Construct a new\n            ExtensionArray from a sequence of strings.\n        api.extensions.ExtensionArray._hash_pandas_object : Hook for\n            hash_pandas_object.\n\n        Examples\n        --------\n        >>> pd.arrays.IntegerArray._from_sequence([4, 5])\n        <IntegerArray>\n        [4, 5]\n        Length: 2, dtype: Int64\n        \"\"\"\n        raise AbstractMethodError(cls)\n\n    @classmethod\n    def _from_sequence_of_strings(\n        cls, strings, *, dtype: ExtensionDtype, copy: bool = False\n    ) -> Self:\n        \"\"\"\n        Construct a new ExtensionArray from a sequence of strings.\n\n        This method is used to parse string data into the appropriate\n        scalar type for the ExtensionArray. It is commonly used when\n        reading data from text files via parsers like ``read_csv``.\n\n        Parameters\n        ----------\n        strings : Sequence\n            Each element will be an instance of the scalar type for this\n            array, ``cls.dtype.type``.\n        dtype : ExtensionDtype","sourceCodeStart":316,"sourceCodeEnd":352,"githubUrl":"https://github.com/pandas-dev/pandas/blob/3b7651241d4da534b3559b60ef128e1c34f54116/pandas/core/arrays/base.py#L316-L352","documentation":"Raised (AbstractMethodError, a NotImplementedError subclass) from the base ExtensionArray._from_sequence classmethod when a concrete ExtensionArray subclass has not overridden it. `_from_sequence` is the canonical constructor that turns a 1-D sequence of scalars into an instance; the base implementation only exists to give a clear error. The message uses methodtype='classmethod' so it reads 'This classmethod must be defined in the concrete class <name>'.","triggerScenarios":"Subclassing ExtensionArray without implementing `_from_sequence`, then calling `MyArray._from_sequence([...])` (directly or via pandas internals like `pandas.array`/casting).","commonSituations":"Writing a custom extension array and forgetting the mandatory construction classmethods; partial implementations that only override `_from_factorized`.","solutions":["Implement `_from_sequence(cls, scalars, *, dtype=None, copy=False)` in your ExtensionArray subclass and return a new instance.","If you are just consuming an existing array type and hit this, the type is incompletely implemented — file/fix it upstream rather than working around it."],"exampleFix":"# before\nclass MyArray(ExtensionArray):\n    ...\n# after\nclass MyArray(ExtensionArray):\n    @classmethod\n    def _from_sequence(cls, scalars, *, dtype=None, copy=False):\n        data = np.array(scalars, dtype=object)\n        return cls(data)","handlingStrategy":"validation","validationCode":"from pandas.api.extensions import ExtensionArray\nif '_from_sequence' not in vars(type(my_array)):\n    raise TypeError(f\"{type(my_array).__name__} does not implement _from_sequence\")\ntype(my_array)._from_sequence(scalars)","typeGuard":"def implements_from_sequence(arr_cls) -> bool:\n    return '_from_sequence' in vars(arr_cls)","tryCatchPattern":"try:\n    out = MyArray._from_sequence(scalars)\nexcept AbstractMethodError:\n    raise AbstractMethodError(f\"Implement _from_sequence on {MyArray.__name__}\")","preventionTips":["Implement all required ExtensionArray abstract methods when subclassing","Add a conformance test that calls each mandatory method on a sample instance"],"tags":["extension-array","abstract-method","subclassing","api-contract"],"backgroundTag":null,"analyzedSha":"3b7651241d4da534b3559b60ef128e1c34f54116","analyzedAt":"2026-08-11T22:10:44.015Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}