pandas-dev/pandas · error · AbstractMethodError
This method must be defined in the concrete class {name}
Error message
This method must be defined in the concrete class {name} What it means
Raised (AbstractMethodError) from the base ExtensionArray._from_sequence_of_strings classmethod when a subclass has not overridden it. This method parses string input (e.g. from read_csv) into the extension array's scalar type; the base stub exists solely to surface a precise error instead of a generic NotImplementedError. Unlike _from_sequence it is not strictly abstract for all types, but anything that can be read from text must define it.
Source
Thrown at pandas/core/arrays/base.py:378
ExtensionArray
See Also
--------
api.extensions.ExtensionArray._from_sequence : Construct a new ExtensionArray
from a sequence of scalars.
api.extensions.ExtensionArray._from_factorized : Reconstruct an ExtensionArray
after factorization.
Examples
--------
>>> pd.arrays.IntegerArray._from_sequence_of_strings(
... ["1", "2", "3"], dtype=pd.Int64Dtype()
... )
<IntegerArray>
[1, 2, 3]
Length: 3, dtype: Int64
"""
raise AbstractMethodError(cls)
@classmethod
def _from_factorized(cls, values, original):
"""
Reconstruct an ExtensionArray after factorization.
This method reverses the encoding applied by :meth:`factorize`,
recreating an ExtensionArray from the unique values and original
array metadata.
Parameters
----------
values : ndarray
An integer ndarray with the factorized values.
original : ExtensionArray
The original ExtensionArray that factorize was called on.
See AlsoView on GitHub (pinned to 3b7651241d)
Solutions
- Implement `_from_sequence_of_strings(cls, strings, *, dtype, copy=False)` in your subclass, parsing each string into the scalar type.
- If your dtype is never constructed from strings, leave it unimplemented and avoid routing string input into it.
Example fix
# before
class MyArray(ExtensionArray):
...
# after
class MyArray(ExtensionArray):
@classmethod
def _from_sequence_of_strings(cls, strings, *, dtype, copy=False):
scalars = [_parse(s) for s in strings]
return cls._from_sequence(scalars, dtype=dtype, copy=copy) Defensive patterns
Strategy: validation
Validate before calling
if '_from_sequence_of_strings' not in vars(type(my_array)):
raise TypeError(f"{type(my_array).__name__} cannot parse from strings")
type(my_array)._from_sequence_of_strings(strings, dtype=dtype) Type guard
def implements_from_strings(arr_cls) -> bool:
return '_from_sequence_of_strings' in vars(arr_cls) Try / catch
try:
out = MyArray._from_sequence_of_strings(strings, dtype=dtype)
except AbstractMethodError:
raise AbstractMethodError(f"Implement _from_sequence_of_strings on {MyArray.__name__} to parse from text") Prevention
- Implement _from_sequence_of_strings if your dtype is read from CSV
- Gate string parsing tests behind this method's presence
When it happens
Trigger: Calling `MyArray._from_sequence_of_strings([...], dtype=...)` on a custom ExtensionArray that did not override it; routing string data into a custom dtype via read_csv/pandas.array.
Common situations: Custom extension dtype intended to be parseable from CSV but missing the string-parsing constructor; tests that exercise the read_csv path for a new dtype.
Related errors
- This method must be defined in the concrete class {name}
- This classmethod must be defined in the concrete class {name
- {type(self)} does not implement __setitem__.
- cannot diff {type(arr).__name__} on axis={axis}
- {type(arr).__name__} has no 'diff' method. Convert to a suit
AI-assisted analysis of pandas-dev/pandas@3b7651241d (2026-08-11).
Data as JSON: /api/errors/b8b165acc155827d.
Report an issue: GitHub.