BUG: ArrowExtensionArray logical_op not working in all directions · Issue #52625 · pandas-dev/pandas (original) (raw)
a = pd.Series( data = [True, True, False], dtype = pd.BooleanDtype() ) b = pd.Series( data = [True, True, False], dtype = "boolean[pyarrow]" )
a & b 0 True 1 True 2 False dtype: boolean
b & a
NotImplementedError Traceback (most recent call last)
Cell In[209], line 1
----> 1 b & a
File c:\ProgramData\Miniconda3\envs\DLL_ETL\lib\site-packages\pandas\core\ops\common.py:81, in _unpack_zerodim_and_defer..new_method(self, other)
77 return NotImplemented
79 other = item_from_zerodim(other)
---> 81 return method(self, other)
File c:\ProgramData\Miniconda3\envs\DLL_ETL\lib\site-packages\pandas\core\arraylike.py:70, in OpsMixin.__and__(self, other)
68 @unpack_zerodim_and_defer("__and__")
69 def __and__(self, other):
---> 70 return self._logical_method(other, operator.and_)
File c:\ProgramData\Miniconda3\envs\DLL_ETL\lib\site-packages\pandas\core\series.py:6108, in Series._logical_method(self, other, op)
6105 lvalues = self._values
6106 rvalues = extract_array(other, extract_numpy=True, extract_range=True)
-> 6108 res_values = ops.logical_op(lvalues, rvalues, op)
6109 return self._construct_result(res_values, name=res_name)
File c:\ProgramData\Miniconda3\envs\DLL_ETL\lib\site-packages\pandas\core\ops\array_ops.py:379, in logical_op(left, right, op)
375 rvalues = right
377 if should_extension_dispatch(lvalues, rvalues):
378 # Call the method on lvalues
--> 379 res_values = op(lvalues, rvalues)
381 else:
382 if isinstance(rvalues, np.ndarray):
File c:\ProgramData\Miniconda3\envs\DLL_ETL\lib\site-packages\pandas\core\ops\common.py:81, in _unpack_zerodim_and_defer..new_method(self, other)
77 return NotImplemented
79 other = item_from_zerodim(other)
---> 81 return method(self, other)
File c:\ProgramData\Miniconda3\envs\DLL_ETL\lib\site-packages\pandas\core\arraylike.py:70, in OpsMixin.__and__(self, other)
68 @unpack_zerodim_and_defer("__and__")
69 def __and__(self, other):
---> 70 return self._logical_method(other, operator.and_)
File c:\ProgramData\Miniconda3\envs\DLL_ETL\lib\site-packages\pandas\core\arrays\arrow\array.py:503, in ArrowExtensionArray._logical_method(self, other, op)
502 def _logical_method(self, other, op):
--> 503 return self._evaluate_op_method(other, op, ARROW_LOGICAL_FUNCS)
File c:\ProgramData\Miniconda3\envs\DLL_ETL\lib\site-packages\pandas\core\arrays\arrow\array.py:497, in ArrowExtensionArray._evaluate_op_method(self, other, op, arrow_funcs)
495 result = pc_func(self._data, pa_scalar)
496 else:
--> 497 raise NotImplementedError(
498 f"{op.__name__} not implemented for {type(other)}"
499 )
500 return type(self)(result)
Logical operations don't work in all directions.
Issue seems to be pd.BooleanDtype() as it works for