From 09d58a92295c29564f5da22b65166d28bdf8fbdb Mon Sep 17 00:00:00 2001 From: Hassan Kibirige Date: Mon, 30 Sep 2019 22:56:57 +0300 Subject: [PATCH] TST: Add test for categorical with str and tuples The bug is not present any more. closes #21416 --- pandas/tests/arrays/categorical/test_constructors.py | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/pandas/tests/arrays/categorical/test_constructors.py b/pandas/tests/arrays/categorical/test_constructors.py index 704f9c94463e6..237ec17f56974 100644 --- a/pandas/tests/arrays/categorical/test_constructors.py +++ b/pandas/tests/arrays/categorical/test_constructors.py @@ -3,6 +3,8 @@ import numpy as np import pytest +from pandas.compat.numpy import _np_version_under1p16 + from pandas.core.dtypes.common import is_float_dtype, is_integer_dtype from pandas.core.dtypes.dtypes import CategoricalDtype @@ -601,3 +603,10 @@ def test_constructor_imaginary(self): c1 = Categorical(values) tm.assert_index_equal(c1.categories, Index(values)) tm.assert_numpy_array_equal(np.array(c1), np.array(values)) + + @pytest.mark.skipif(_np_version_under1p16, reason="Skipping for NumPy <1.16") + def test_constructor_string_and_tuples(self): + # GH 21416 + c = pd.Categorical(["c", ("a", "b"), ("b", "a"), "c"]) + expected_index = pd.Index([("a", "b"), ("b", "a"), "c"]) + assert c.categories.equals(expected_index)