Skip to content

Conversation

@majiayu000
Copy link

Summary

Fix comp_method_OBJECT_ARRAY to return BooleanArray when input contains pd.NA values, ensuring NA is properly propagated in comparison results instead of returning False.

Problem

Previously, when comparing an object dtype Series containing pd.NA with a scalar:

x = pd.Series([1, 2, pd.NA])
x[2] == 3  # Returns <NA> (correct)
x == 3     # Returns [False, False, False] (incorrect - third element should be <NA>)

Solution

Modified comp_method_OBJECT_ARRAY to detect pd.NA values in the input and return a BooleanArray with proper NA masking instead of a plain boolean array.

After fix

x = pd.Series([1, 2, pd.NA])
x[2] == 3  # Returns <NA>
x == 3     # Returns [False, False, <NA>] (now consistent)

Closes #63328

majiayu000 and others added 2 commits December 11, 2025 18:23
Fix comp_method_OBJECT_ARRAY to return BooleanArray when input contains
pd.NA values, ensuring NA is properly propagated in comparison results
instead of returning False.

Closes pandas-dev#63328
Fix `comp_method_OBJECT_ARRAY` to return `BooleanArray` when input contains
`pd.NA` values, ensuring NA is properly propagated in comparison results
instead of returning `False`.

Previously, when comparing an object dtype Series containing `pd.NA` with
a scalar, the vectorized comparison would return `False` for NA positions
instead of `<NA>`.

Closes pandas-dev#63328

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

BUG: inconsistency with missing values comparison

1 participant