pandas-dev/pandas · error · TypeError

operation '{op.__name__}' not supported for dtype '{self.dty

Error message

operation '{op.__name__}' not supported for dtype '{self.dtype}' with {other_type}

What it means

Raised by _evaluate_op_method during string add/radd when pyarrow's pc.binary_join_element_wise raises ArrowNotImplementedError (e.g. adding incompatible types that can't be joined as strings). The except branch converts the pyarrow failure into a TypeError with the op name and other's type/dtype, matching pandas' arithmetic-error conventions. Only reached for string/large_string/binary pa_type.

Source

Thrown at pandas/core/arrays/arrow/array.py:1186

                # want to allow addition between string and large_string types
                self_array = self._pa_array
                if pa.types.is_string(pa_type) and pa.types.is_large_string(other.type):
                    self_array = self._pa_array.cast(pa.large_string())
                elif pa.types.is_large_string(pa_type) and pa.types.is_string(
                    other.type
                ):
                    other = other.cast(pa.large_string())

                sep = pa.scalar("", type=self_array.type)
                if isinstance(other, pa.Scalar) and pc.is_null(other).as_py():
                    other = other.cast(self_array.type)
                try:
                    if op is operator.add:
                        result = pc.binary_join_element_wise(self_array, other, sep)
                    elif op is roperator.radd:
                        result = pc.binary_join_element_wise(other, self_array, sep)
                except pa.ArrowNotImplementedError as err:
                    raise TypeError(
                        self._op_method_error_message(other_original, op)
                    ) from err
                return self._from_pyarrow_array(result)
            elif op in [operator.mul, roperator.rmul]:
                binary = self._pa_array
                integral = other
                if not pa.types.is_integer(integral.type):
                    raise TypeError("Can only string multiply by an integer.")
                pa_integral = pc.if_else(pc.less(integral, 0), 0, integral)
                result = pc.binary_repeat(binary, pa_integral)
                return self._from_pyarrow_array(result)
        elif (
            pa.types.is_string(other.type)
            or pa.types.is_binary(other.type)
            or pa.types.is_large_string(other.type)
        ) and op in [operator.mul, roperator.rmul]:
            binary = other
            integral = self._pa_array

View on GitHub (pinned to 71959b8cb9)

Solutions

  1. Explicitly stringify the other operand: s + other.astype('string[pyarrow]').
  2. Cast both operands to the same string type (string vs large_string).
  3. Use the object-dtype fallback path by casting via .astype(object).
  4. Pre-validate dtypes align before the operation.

Example fix

# before
out = names + ids   # ids is int64[pyarrow] -> TypeError
# after
out = names + ids.astype('string[pyarrow]')
Defensive patterns

Strategy: validation

Validate before calling

import pyarrow as pa

def str_add(arr, other):
    other_typed = other.astype('string[pyarrow]') if hasattr(other, 'astype') else pa.scalar(str(other), type=pa.string())
    return arr + other_typed

out = str_add(names, ids)

Type guard

import pyarrow as pa

def is_string_compatible(other) -> bool:
    if hasattr(other, 'dtype'):
        from pandas.api.types import is_string_dtype
        return is_string_dtype(other)
    return isinstance(other, (str, bytes, pa.Scalar))

Try / catch

try:
    out = s + other
except TypeError as e:
    if 'not supported for dtype' in str(e) and 'string' in str(s.dtype):
        out = s + other.astype('string[pyarrow]')
    else:
        raise

Prevention

When it happens

Trigger: `s + obj` where s is string[pyarrow] and the other operand's type cannot be coerced into a joinable string by pyarrow — e.g. adding a complex object, a mismatched binary type, or a column whose cast fails. Falls back to _str_arith_method_object_fallback only for ArrowInvalid/ArrowTypeError at the _arith_method level, but a NotImplementedError here surfaces.

Common situations: Concatenating string columns with numeric columns expecting automatic str() coercion (pyarrow is stricter than object dtype), adding None-typed scalars, or mixing large_string/string with incompatible binary.

Related errors


AI-assisted analysis of pandas-dev/pandas@71959b8cb9 (2026-08-07). Data as JSON: /api/errors/d9220d32e43bde80. Report an issue: GitHub.