Skip to content

Commit e732fb9

Browse files
committed
un-comment-out, remove duplicate check
1 parent ea40e3d commit e732fb9

File tree

2 files changed

+6
-10
lines changed

2 files changed

+6
-10
lines changed

pandas/core/indexes/category.py

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@
2222
from pandas.core.dtypes.dtypes import CategoricalDtype
2323
from pandas.core.dtypes.missing import (
2424
is_valid_na_for_dtype,
25-
isna,
2625
)
2726

2827
from pandas.core.arrays.categorical import (
@@ -272,12 +271,6 @@ def _is_dtype_compat(self, other: Index) -> Categorical:
272271
)
273272
cat = other._values
274273

275-
if not ((cat == values) | (isna(cat) & isna(values))).all():
276-
# GH#37667 see test_equals_non_category
277-
raise TypeError(
278-
"categories must match existing categories when appending"
279-
)
280-
281274
return cat
282275

283276
def equals(self, other: object) -> bool:

pandas/tests/dtypes/test_dtypes.py

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import re
2+
import warnings
23
import weakref
34

45
import numpy as np
@@ -121,15 +122,17 @@ def test_constructor_invalid(self):
121122

122123
dtype1 = CategoricalDtype(["a", "b"], ordered=True)
123124
dtype2 = CategoricalDtype(["x", "y"], ordered=False)
124-
# c = Categorical([0, 1], dtype=dtype1)
125+
with warnings.catch_warnings():
126+
warnings.filterwarnings("ignore")
127+
c = Categorical([0, 1], dtype=dtype1)
125128

126129
@pytest.mark.parametrize(
127130
"values, categories, ordered, dtype, expected",
128131
[
129132
[None, None, None, None, CategoricalDtype()],
130133
[None, ["a", "b"], True, None, dtype1],
131-
# [c, None, None, dtype2, dtype2],
132-
# [c, ["x", "y"], False, None, dtype2],
134+
[c, None, None, dtype2, dtype2],
135+
[c, ["x", "y"], False, None, dtype2],
133136
],
134137
)
135138
def test_from_values_or_dtype(self, values, categories, ordered, dtype, expected):

0 commit comments

Comments
 (0)