Skip to content

BUG: Fix assert_series_equal for categoricals with nulls and check_category_order=False (#62008) #62011

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 31 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
31 commits
Select commit Hold shift + click to select a range
f3829fd
BUG : Fix Series.str.contains with compiled regex on Arrow string
Aniketsy Jul 25, 2025
c2a64fa
BUG: Fix handling of compiled regex in Series.str.contains for Arrow-…
Aniketsy Jul 25, 2025
838b1c5
BUG: Fix handling of compiled regex in Series.str.contains for Arrow-…
Aniketsy Jul 25, 2025
563f1f1
STYLE: Fix formatting and docstring issues in str.contains
Aniketsy Jul 25, 2025
fda5619
Fixed ruff format
Aniketsy Jul 25, 2025
324e609
Move fix into _str_contains of ArrowExtensionArray
Aniketsy Jul 26, 2025
b474604
Move fix into _str_contains of ArrowExtensionArray
Aniketsy Jul 26, 2025
3345bc7
Revert changes to pandas/core/strings/accessor.py from PR #61946
Aniketsy Jul 26, 2025
9f06042
Move fix into _str_contains of ArrowExtensionArray
Aniketsy Jul 26, 2025
cbab096
Move fix into _str_contains of ArrowExtensionArray
Aniketsy Jul 26, 2025
d88f8d1
BUG: Fix Series.str.contains with compiled regex and arrow strings (#…
Aniketsy Jul 28, 2025
a0decbc
Revert changes to pandas/core/arrays/arrow/array.py in PR
Aniketsy Jul 28, 2025
8fc81e0
BUG: Fix Series.str.contains with compiled regex on Arrow string dtyp…
Aniketsy Jul 28, 2025
8e226cd
BUG: Fix Series.str.contains with compiled regex on Arrow string dtyp…
Aniketsy Jul 28, 2025
6768fb1
BUG: Fix Series.str.contains with compiled regex on Arrow string dtyp…
Aniketsy Jul 29, 2025
05ae24f
BUG: Fix Series.str.contains with compiled regex on Arrow string dtyp…
Aniketsy Jul 29, 2025
702384d
Revert changes to test_strings.py
Aniketsy Jul 29, 2025
0be9a18
BUG: Fix Series.str.contains with compiled regex on Arrow string dtyp…
Aniketsy Jul 29, 2025
4ddc7db
BUG: Fix Series.str.contains with compiled regex on Arrow string dtyp…
Aniketsy Jul 29, 2025
9a7e640
BUG: Fix Series.str.contains with compiled regex on Arrow string dtyp…
Aniketsy Jul 29, 2025
b00fbe0
BUG: Fix Series.str.contains with compiled regex on Arrow string dtyp…
Aniketsy Jul 29, 2025
76f741c
Revert test_strings.py changes and remove accidental whatsnew file
Aniketsy Jul 29, 2025
8e65078
Revert test_strings.py changes and remove accidental whatsnew file
Aniketsy Jul 29, 2025
4912758
Merge remote-tracking branch 'upstream/main' into fix-arrow-contains-…
Aniketsy Jul 30, 2025
0e620ca
BUG: Fix Series.str.contains with compiled regex on Arrow string dtyp…
Aniketsy Jul 30, 2025
915b38f
BUG: Fix Series.str.contains with compiled regex on Arrow string dtyp…
Aniketsy Jul 30, 2025
355b143
BUG: Implement elementwise IntervalArray.overlaps (#62004)
Aniketsy Jul 30, 2025
fa77cec
BUG: Fix assert_series_equal for categoricals with nulls and check_ca…
Aniketsy Jul 31, 2025
116d0f9
Revert unintended changes to interval.py
Aniketsy Jul 31, 2025
d1f872b
Remove unintended changes to test_interval.py
Aniketsy Jul 31, 2025
24ac0d7
BUG: Fix assert_series_equal for categoricals with nulls and check_ca…
Aniketsy Jul 31, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 0 additions & 34 deletions doc/source/whatsnew/v2.3.2.rst

This file was deleted.

11 changes: 9 additions & 2 deletions pandas/_testing/asserters.py
Original file line number Diff line number Diff line change
Expand Up @@ -495,8 +495,15 @@ def assert_categorical_equal(
lc, rc = left.categories, right.categories
assert_index_equal(lc, rc, obj=f"{obj}.categories", exact=exact)
assert_index_equal(
left.categories.take(left.codes),
right.categories.take(right.codes),
Index(
[left.categories[code] if code >= 0 else np.nan for code in left.codes]
),
Index(
[
right.categories[code] if code >= 0 else np.nan
for code in right.codes
]
),
obj=f"{obj}.values",
exact=exact,
)
Expand Down
13 changes: 13 additions & 0 deletions pandas/tests/util/test_assert_categorical_equal.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import numpy as np
import pytest

from pandas import Categorical
Expand Down Expand Up @@ -86,3 +87,15 @@ def test_categorical_equal_object_override(obj):

with pytest.raises(AssertionError, match=msg):
tm.assert_categorical_equal(c1, c2, obj=obj)


def test_categorical_equal_with_nans_and_different_order():
# GH#62008
values = ["B", np.nan, "D"]
categories_left = ["B", "D"]
categories_right = categories_left[::-1]

left = Categorical(values, categories=categories_left)
right = Categorical(values, categories=categories_right)

tm.assert_categorical_equal(left, right, check_category_order=False)
Loading