pandas-dev/pandas · error · NotImplementedError
Converting strings to {pa_type} is not implemented.
Error message
Converting strings to {pa_type} is not implemented. What it means
Raised by _from_sequence_of_strings when the target pa_type is not one of the string-convertible types handled (string/binary/timestamp/date/duration/time/bool/int/float/decimal). This path is used when constructing an ArrowExtensionArray from a sequence of strings with a given ArrowDtype. Any pyarrow type outside the enumerated set (e.g. list_, struct, fixed_size_binary, month_day_nano_interval, large_binary variants not special-cased) raises NotImplementedError.
Source
Thrown at pandas/core/arrays/arrow/array.py:496
scalars = pc.if_else(pc.equal(scalars, "0.0"), "0", scalars)
scalars = scalars.cast(pa.bool_())
elif (
pa.types.is_integer(pa_type)
or pa.types.is_floating(pa_type)
or pa.types.is_decimal(pa_type)
):
from pandas.core.tools.numeric import to_numeric
scalars = to_numeric(strings, errors="raise")
if is_pa_array:
scalars = strings.cast(pa_type)
else:
mask = isna(strings)
if mask is not None:
scalars = pa.array(scalars, mask=mask, type=pa_type)
else:
raise NotImplementedError(
f"Converting strings to {pa_type} is not implemented."
)
return cls._from_sequence(scalars, dtype=pa_type, copy=copy)
def _from_pyarrow_array(self, pa_array):
"""
Construct from a pyarrow Array/ChunkedArray result of an operation.
Avoids full __init__ overhead by reusing the dtype when the pyarrow
type is unchanged.
"""
assert isinstance(pa_array, (pa.Array, pa.ChunkedArray))
obj = type(self).__new__(type(self))
if isinstance(pa_array, pa.Array):
pa_array = pa.chunked_array([pa_array])
obj._pa_array = pa_array
pa_type = pa_array.type
obj._dtype = (View on GitHub (pinned to 71959b8cb9)
Solutions
- Pre-convert the strings to a pyarrow array yourself and pass values, not strings: pa.array(parsed_lists, type=pa.list_(pa.int64())).
- Use a supported intermediate dtype first (e.g. object) then cast.
- Switch to a non-pyarrow dtype for the conversion step and convert_dtypes() afterwards.
- For list/struct types, build the pa.Array from already-typed Python objects via _from_sequence.
Example fix
# before import pyarrow as pa import pandas as pd arr = pd.array(['[1,2]','[3]'], dtype=pd.ArrowDtype(pa.list_(pa.int64()))) # NotImplementedError # after - parse first, then build parsed = [[1,2],[3]] arr = pd.array(parsed, dtype=pd.ArrowDtype(pa.list_(pa.int64())))
Defensive patterns
Strategy: validation
Validate before calling
import pyarrow as pa
SUPPORTED_FOR_STR_CONV = (
pa.types.is_string, pa.types.is_large_string, pa.types.is_binary,
pa.types.is_timestamp, pa.types.is_date, pa.types.is_duration,
pa.types.is_time, pa.types.is_boolean, pa.types.is_integer,
pa.types.is_floating, pa.types.is_decimal,
)
def can_convert_strings(pa_type) -> bool:
return any(check(pa_type) for check in SUPPORTED_FOR_STR_CONV)
# before: pd.array(strings, dtype=pd.ArrowDtype(pa_type))
if not can_convert_strings(pa_type):
parsed = pre_parse(strings, pa_type) # your parser
arr = pd.array(parsed, dtype=pd.ArrowDtype(pa_type))
else:
arr = pd.array(strings, dtype=pd.ArrowDtype(pa_type)) Type guard
import pyarrow as pa
def is_string_convertible_arrow_type(t) -> bool:
checks = (
pa.types.is_string, pa.types.is_large_string, pa.types.is_binary,
pa.types.is_timestamp, pa.types.is_date, pa.types.is_duration,
pa.types.is_time, pa.types.is_boolean, pa.types.is_integer,
pa.types.is_floating, pa.types.is_decimal,
)
return any(c(t) for c in checks) Try / catch
try:
arr = pd.array(strings, dtype=pd.ArrowDtype(pa_type))
except NotImplementedError as e:
if 'Converting strings to' in str(e):
parsed = pre_parse(strings, pa_type)
arr = pd.array(parsed, dtype=pd.ArrowDtype(pa_type))
else:
raise Prevention
- Pre-parse complex types (list/struct) into Python objects before pd.array.
- Test string->dtype conversion for any new ArrowDtype at the boundary.
- Keep a whitelist of supported pa_types for string ingestion.
When it happens
Trigger: Building a pyarrow-backed array from strings into an unsupported dtype: `pd.array(['1','2'], dtype=ArrowDtype(pa.list_(pa.int64())))`, or `_from_sequence_of_strings(strings, dtype=ArrowDtype(pa.struct([...])))`, or interval/temporal-with-timezone types not yet handled.
Common situations: Parsing CSV/string columns into complex Arrow types (lists, structs) expecting automatic inference; using pd.Series([...strings...], dtype=ArrowDtype(some_complex_type)); upgrading pandas/pyarrow and hitting a newly-added pa_type not yet supported by the string-conversion ladder.
Related errors
- replace is not supported with a re.Pattern, callable repl, c
- contains not implemented with {flags=}
- {op.__name__} not implemented for {type(other)}
- repeat is not implemented when repeats is {type(repeats).__n
- Only flags=0 is implemented.
AI-assisted analysis of pandas-dev/pandas@71959b8cb9 (2026-08-07).
Data as JSON: /api/errors/93233f43a5f5dec8.
Report an issue: GitHub.