{"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":1127,"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":1109,"sourceCodeEnd":1145,"githubUrl":"https://github.com/pandas-dev/pandas/blob/71959b8cb9b2459c16e14b34f28b178ccfe14735/pandas/core/arrays/arrow/array.py#L1109-L1145","documentation":"Raised by ArrowExtensionArray._cmp_method when `other` is neither array-like (ExtensionArray/ndarray/list/range) nor a scalar (is_scalar True). This final else branch catches unexpected comparator operands such as custom Python objects, dicts, or multi-dimensional arrays. It is a defensive NotImplementedError signalling the comparison cannot be dispatched.","triggerScenarios":"Comparing an ArrowExtensionArray with a dict, a 2-D array, a custom object, or a pandas DataFrame: `arr == {'a':1}`, `arr < some_object`, `arr == df`. is_scalar(dict) is False and dict is not in the array-like isinstance tuple.","commonSituations":"Passing a mapping as a comparison value expecting per-key lookup; comparing against an unintended object (e.g. a column reference vs a scalar); edge cases with pandas objects whose is_scalar is False.","solutions":["Extract a scalar or array before comparing: arr == df['col'].values.","If comparing to a mapping, resolve values explicitly first.","Ensure `other` is a scalar, list, ndarray, range, or ExtensionArray.","Wrap heterogeneous comparisons and handle unsupported operands explicitly."],"exampleFix":"# before\nmask = arrow_arr == {'a': 1}  # NotImplementedError\n# after\nmask = arrow_arr == some_scalar\n# or align a Series\nmask = (arrow_arr == pd.Series([1,2,3], dtype=arrow_arr.dtype))._pa_array","handlingStrategy":"type-guard","validationCode":"from pandas.api.types import is_scalar, is_list_like\n\ndef safe_compare(arr, other):\n    if not (is_scalar(other) or is_list_like(other) or isinstance(other, (list, range))):\n        raise TypeError(f'unsupported comparison operand {type(other)}')\n    return arr == other\n\nmask = safe_compare(arrow_arr, operand)","typeGuard":"from pandas.api.types import is_scalar\nimport numpy as np\nfrom pandas.arrays import ExtensionArray\n\ndef is_comparable_operand(other) -> bool:\n    return is_scalar(other) or isinstance(other, (list, range, np.ndarray, ExtensionArray))","tryCatchPattern":"try:\n    mask = arr == other\nexcept NotImplementedError as e:\n    if 'not implemented for' in str(e):\n        # coerce to a comparable form\n        mask = arr == np.asarray(other)\n    else:\n        raise","preventionTips":["Resolve mappings/dicts to concrete values before comparing.","Use .values or scalar extraction for operand alignment.","Reject unsupported operand types at API boundaries."],"tags":["pyarrow","comparison","operand-validation","not-implemented"],"analyzedSha":"71959b8cb9b2459c16e14b34f28b178ccfe14735","analyzedAt":"2026-08-07T01:30:20.476Z","schemaVersion":2},"datasetVersion":"2026-08-07T03:17:09.362Z"}