Skip to content

Commit 01887f8

Browse files
committed
BUG (string dtype): comparison of string column to mixed object column fails pandas-dev#60228
1 parent b301ac0 commit 01887f8

File tree

1 file changed

+5
-12
lines changed

1 file changed

+5
-12
lines changed

pandas/core/arrays/arrow/array.py

+5-12
Original file line numberDiff line numberDiff line change
@@ -726,21 +726,14 @@ def _cmp_method(self, other, op) -> ArrowExtensionArray:
726726
other, (ArrowExtensionArray, np.ndarray, list, BaseMaskedArray)
727727
) or isinstance(getattr(other, "dtype", None), CategoricalDtype):
728728
try:
729-
other_array = self._box_pa(other)
730-
if isinstance(other_array.type, pa.DictionaryType):
731-
other_array = other_array.dictionary_decode()
732-
if pa.types.is_string(other_array.type):
733-
other_array = other_array.cast(pa.string())
734729
if pa.types.is_string(self._pa_array.type):
735-
self_array = self._pa_array
736-
if not pa.types.is_string(other_array.type):
737-
other_array = other_array.cast(pa.string())
730+
other_array = self._box_pa(other)
731+
self_array = self._pa_array.cast(pa.large_string())
732+
if pa.types.is_string(other_array.type):
733+
other_array = other_array.cast(pa.large_string())
738734
result = pc_func(self_array, other_array)
739735
else:
740-
result = pc_func(self._pa_array, other_array)
741-
if result.type == pa.string():
742-
result = result.cast(self._pa_array.type)
743-
return type(self)(result)
736+
result = pc_func(self._pa_array, self._box_pa(other))
744737
except pa.ArrowNotImplementedError:
745738
# TODO: could this be wrong if other is object dtype?
746739
# in which case we need to operate pointwise?

0 commit comments

Comments
 (0)