{"record":{"id":"860d001829f037da","repo":"pandas-dev/pandas","slug":"op-name-not-implemented-for-type-other","errorCode":null,"errorMessage":"{op.__name__} not implemented for {type(other)}","messagePattern":"(.+?) not implemented for (.+?)","errorType":"exception","errorClass":"NotImplementedError","httpStatus":null,"severity":"error","filePath":"pandas/core/arrays/arrow/array.py","lineNumber":1152,"sourceCode":"                # GH#62157 match non-pyarrow behavior\n                result = ops.invalid_comparison(self, other, op)\n                result = pa.array(result, type=pa.bool_())\n            else:\n                try:\n                    result = pc_func(self._pa_array, self._box_pa(other))\n                except (pa.lib.ArrowNotImplementedError, pa.lib.ArrowInvalid):\n                    mask = isna(self) | isna(other)\n                    valid = ~mask\n                    result = np.zeros(len(self), dtype=\"bool\")\n                    np_array = np.array(self)\n                    try:\n                        result[valid] = op(np_array[valid], other)\n                    except TypeError:\n                        result = ops.invalid_comparison(self, other, op)\n                    result = pa.array(result, type=pa.bool_())\n                    result = pc.if_else(valid, result, None)\n        else:\n            raise NotImplementedError(\n                f\"{op.__name__} not implemented for {type(other)}\"\n            )\n        return ArrowExtensionArray(result)\n\n    def _op_method_error_message(self, other, op) -> str:\n        if hasattr(other, \"dtype\"):\n            other_type = f\"dtype '{other.dtype}'\"\n        else:\n            other_type = f\"object of type {type(other)}\"\n        return (\n            f\"operation '{op.__name__}' not supported for \"\n            f\"dtype '{self.dtype}' with {other_type}\"\n        )\n\n    def _evaluate_op_method(self, other, op, arrow_funcs) -> Self:\n        if (\n            is_list_like(other)\n            and not isinstance(other, (np.ndarray, ExtensionArray, list))","sourceCodeStart":1134,"sourceCodeEnd":1170,"githubUrl":"https://github.com/pandas-dev/pandas/blob/3b7651241d4da534b3559b60ef128e1c34f54116/pandas/core/arrays/arrow/array.py#L1134-L1170","documentation":"Raised by ArrowExtensionArray._cmp_method when the `other` operand of a comparison is neither array-like (ExtensionArray/ndarray/list/range) nor a recognized scalar. This is the terminal else-branch: pandas does not know how to broadcast a comparison against an arbitrary object, so it raises NotImplementedError naming the operand's type.","triggerScenarios":"Comparing an ArrowExtensionArray against a custom Python object, a dict, a tuple, a set, or a pyarrow Scalar that escaped the is_scalar check; arr == some_object where some_object.__eq__ does not cooperate.","commonSituations":"User-defined types passed as comparison operands; passing a row from a DataFrame (a Series) works, but a raw dict/tuple does not; comparing against a pa.Scalar directly.","solutions":["Convert the operand to a scalar or array-like first: list(other), np.asarray(other), or wrap in a Series.","If it is a pyarrow Scalar, call .as_py() to get a native Python scalar before comparing.","Implement __eq__/__lt__ on your custom type returning a comparable scalar.","Avoid comparing against containers like dict/set that have no elementwise semantics."],"exampleFix":"# before\nimport pyarrow as pa\narr = pd.array([1, 2, 3], dtype=\"int64[pyarrow]\")\narr == pa.scalar(2)  # pa.Scalar is not 'is_scalar' -> NotImplementedError\n\n# after\narr == pa.scalar(2).as_py()","handlingStrategy":"type-guard","validationCode":"import pyarrow as pa\nfrom pandas.api.types import is_scalar, is_list_like\n\ndef normalize_operand(other):\n    if isinstance(other, pa.Scalar):\n        return other.as_py()\n    if is_list_like(other) and not isinstance(other, (list, range)):\n        return list(other)\n    return other","typeGuard":"import pyarrow as pa\nfrom pandas.api.types import is_scalar\n\ndef is_cmp_operand(other) -> bool:\n    if isinstance(other, pa.Scalar):\n        return False  # must call .as_py() first\n    return is_scalar(other) or hasattr(other, 'dtype') or isinstance(other, (list, range))","tryCatchPattern":null,"preventionTips":["Convert pa.Scalar via .as_py() before comparing.","Wrap custom objects in a comparable scalar or a list.","Avoid comparing against dict/set/tuple containers."],"tags":["comparison","operand","type-validation","pyarrow"],"backgroundTag":null,"analyzedSha":"3b7651241d4da534b3559b60ef128e1c34f54116","analyzedAt":"2026-08-11T22:10:44.015Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}