@@ -829,12 +829,17 @@ def _cmp_method(self, other, op) -> ArrowExtensionArray:
829
829
pc_func = ARROW_CMP_FUNCS [op .__name__ ]
830
830
if isinstance (other , (ExtensionArray , np .ndarray , list )):
831
831
try :
832
- result = pc_func (self ._pa_array , self ._box_pa (other ))
833
- except pa .ArrowNotImplementedError :
834
- # TODO: could this be wrong if other is object dtype?
835
- # in which case we need to operate pointwise?
836
- result = ops .invalid_comparison (self , other , op )
837
- result = pa .array (result , type = pa .bool_ ())
832
+ boxed = self ._box_pa (other )
833
+ except pa .lib .ArrowInvalid :
834
+ # e.g. GH#60228 [1, "b"] we have to operate pointwise
835
+ res_values = [op (x , y ) for x , y in zip (self , other )]
836
+ result = pa .array (res_values , type = pa .bool_ (), from_pandas = True )
837
+ else :
838
+ try :
839
+ result = pc_func (self ._pa_array , boxed )
840
+ except pa .ArrowNotImplementedError :
841
+ result = ops .invalid_comparison (self , other , op )
842
+ result = pa .array (result , type = pa .bool_ ())
838
843
elif is_scalar (other ):
839
844
try :
840
845
result = pc_func (self ._pa_array , self ._box_pa (other ))
0 commit comments