From e78ff76eb18365ca6677ac4109ae04bfb5d06fb9 Mon Sep 17 00:00:00 2001 From: Parth Kandharkar Date: Sun, 16 Nov 2025 05:59:35 -0800 Subject: [PATCH] BUG: Inconsistency of BooleanArray.__and__ with pd.NA and [pd.NA](fixes #63095) --- pandas/core/arrays/boolean.py | 2 +- pandas/tests/arrays/boolean/test_ops.py | 6 ++++++ 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/pandas/core/arrays/boolean.py b/pandas/core/arrays/boolean.py index 2d7bae7833f29..389854aa8e38d 100644 --- a/pandas/core/arrays/boolean.py +++ b/pandas/core/arrays/boolean.py @@ -397,7 +397,7 @@ def _logical_method(self, other, op): if isinstance(other, BooleanArray): other, mask = other._data, other._mask elif is_list_like(other): - other = np.asarray(other, dtype="bool") + other = np.asarray(other, dtype=object) if other.ndim > 1: return NotImplemented other, mask = coerce_to_array(other, copy=False) diff --git a/pandas/tests/arrays/boolean/test_ops.py b/pandas/tests/arrays/boolean/test_ops.py index 95ebe8528c2e5..8acf502af8517 100644 --- a/pandas/tests/arrays/boolean/test_ops.py +++ b/pandas/tests/arrays/boolean/test_ops.py @@ -25,3 +25,9 @@ def test_abs(self): result = abs(arr) tm.assert_extension_array_equal(result, arr) + + def test_booleanarray_and_list_with_na(self): + b = pd.array([True, False], dtype="boolean") + result = b & [pd.NA, False] + expected = pd.array([pd.NA, False], dtype="boolean") + tm.assert_extension_array_equal(result, expected)