Skip to content

Commit 55538a0

Browse files
has2k1proost
authored andcommitted
TST: Add test for categorical with str and tuples (pandas-dev#28693)
The bug is not present any more. closes pandas-dev#21416
1 parent 412a412 commit 55538a0

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

pandas/tests/arrays/categorical/test_constructors.py

+9
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@
33
import numpy as np
44
import pytest
55

6+
from pandas.compat.numpy import _np_version_under1p16
7+
68
from pandas.core.dtypes.common import is_float_dtype, is_integer_dtype
79
from pandas.core.dtypes.dtypes import CategoricalDtype
810

@@ -601,3 +603,10 @@ def test_constructor_imaginary(self):
601603
c1 = Categorical(values)
602604
tm.assert_index_equal(c1.categories, Index(values))
603605
tm.assert_numpy_array_equal(np.array(c1), np.array(values))
606+
607+
@pytest.mark.skipif(_np_version_under1p16, reason="Skipping for NumPy <1.16")
608+
def test_constructor_string_and_tuples(self):
609+
# GH 21416
610+
c = pd.Categorical(["c", ("a", "b"), ("b", "a"), "c"])
611+
expected_index = pd.Index([("a", "b"), ("b", "a"), "c"])
612+
assert c.categories.equals(expected_index)

0 commit comments

Comments
 (0)