Skip to content

Commit 5672626

Browse files
committed
BUG: Replace in string series with NA (pandas-dev#32621)
Added condition for when to apply the na replacement
1 parent 293a504 commit 5672626

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

pandas/core/internals/managers.py

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1934,10 +1934,11 @@ def _compare_or_regex_search(a, b, regex=False):
19341934
is_a_array = isinstance(a, np.ndarray)
19351935
is_b_array = isinstance(b, np.ndarray)
19361936

1937-
# Comparison with pd.NA is not possible. Replace it's value with np.nan.
1938-
# Based on the definition of isna: np.nan is equal to a pd.NA
1939-
a = np.where(isna(a), np.nan, a)
1940-
b = np.where(isna(b), np.nan, b)
1937+
# Replace all definitions of missing values (isna=True) to a numpy.nan
1938+
if is_a_array:
1939+
a = np.where(isna(a), np.nan, a)
1940+
if is_b_array:
1941+
b = np.where(isna(b), np.nan, b)
19411942

19421943
if is_datetimelike_v_numeric(a, b) or is_numeric_v_string_like(a, b):
19431944
# GH#29553 avoid deprecation warnings from numpy

0 commit comments

Comments
 (0)