{"record":{"id":"d9220d32e43bde80","repo":"pandas-dev/pandas","slug":"operation-op-name-not-supported-for-dtype","errorCode":null,"errorMessage":"operation '{op.__name__}' not supported for dtype '{self.dtype}' with {other_type}","messagePattern":"operation '(.+?)' not supported for dtype '(.+?)' with (.+?)","errorType":"exception","errorClass":"TypeError","httpStatus":null,"severity":"error","filePath":"pandas/core/arrays/arrow/array.py","lineNumber":1186,"sourceCode":"                # want to allow addition between string and large_string types\n                self_array = self._pa_array\n                if pa.types.is_string(pa_type) and pa.types.is_large_string(other.type):\n                    self_array = self._pa_array.cast(pa.large_string())\n                elif pa.types.is_large_string(pa_type) and pa.types.is_string(\n                    other.type\n                ):\n                    other = other.cast(pa.large_string())\n\n                sep = pa.scalar(\"\", type=self_array.type)\n                if isinstance(other, pa.Scalar) and pc.is_null(other).as_py():\n                    other = other.cast(self_array.type)\n                try:\n                    if op is operator.add:\n                        result = pc.binary_join_element_wise(self_array, other, sep)\n                    elif op is roperator.radd:\n                        result = pc.binary_join_element_wise(other, self_array, sep)\n                except pa.ArrowNotImplementedError as err:\n                    raise TypeError(\n                        self._op_method_error_message(other_original, op)\n                    ) from err\n                return self._from_pyarrow_array(result)\n            elif op in [operator.mul, roperator.rmul]:\n                binary = self._pa_array\n                integral = other\n                if not pa.types.is_integer(integral.type):\n                    raise TypeError(\"Can only string multiply by an integer.\")\n                pa_integral = pc.if_else(pc.less(integral, 0), 0, integral)\n                result = pc.binary_repeat(binary, pa_integral)\n                return self._from_pyarrow_array(result)\n        elif (\n            pa.types.is_string(other.type)\n            or pa.types.is_binary(other.type)\n            or pa.types.is_large_string(other.type)\n        ) and op in [operator.mul, roperator.rmul]:\n            binary = other\n            integral = self._pa_array","sourceCodeStart":1168,"sourceCodeEnd":1204,"githubUrl":"https://github.com/pandas-dev/pandas/blob/71959b8cb9b2459c16e14b34f28b178ccfe14735/pandas/core/arrays/arrow/array.py#L1168-L1204","documentation":"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.","triggerScenarios":"`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.","commonSituations":"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.","solutions":["Explicitly stringify the other operand: s + other.astype('string[pyarrow]').","Cast both operands to the same string type (string vs large_string).","Use the object-dtype fallback path by casting via .astype(object).","Pre-validate dtypes align before the operation."],"exampleFix":"# before\nout = names + ids   # ids is int64[pyarrow] -> TypeError\n# after\nout = names + ids.astype('string[pyarrow]')","handlingStrategy":"validation","validationCode":"import pyarrow as pa\n\ndef str_add(arr, other):\n    other_typed = other.astype('string[pyarrow]') if hasattr(other, 'astype') else pa.scalar(str(other), type=pa.string())\n    return arr + other_typed\n\nout = str_add(names, ids)","typeGuard":"import pyarrow as pa\n\ndef is_string_compatible(other) -> bool:\n    if hasattr(other, 'dtype'):\n        from pandas.api.types import is_string_dtype\n        return is_string_dtype(other)\n    return isinstance(other, (str, bytes, pa.Scalar))","tryCatchPattern":"try:\n    out = s + other\nexcept TypeError as e:\n    if 'not supported for dtype' in str(e) and 'string' in str(s.dtype):\n        out = s + other.astype('string[pyarrow]')\n    else:\n        raise","preventionTips":["Cast non-string operands to string[pyarrow] before concatenation.","Avoid mixing string and binary types without explicit casts.","Validate operand dtypes align for string concat."],"tags":["pyarrow","arithmetic","string-dtype","type-error"],"analyzedSha":"71959b8cb9b2459c16e14b34f28b178ccfe14735","analyzedAt":"2026-08-07T01:30:20.476Z","schemaVersion":2},"datasetVersion":"2026-08-07T03:17:09.362Z"}