@@ -146,7 +146,7 @@ class CategoricalDtype(ExtensionDtype):
146
146
def __new__ (cls , categories = None , ordered = False , fastpath = False ):
147
147
from pandas .core .indexes .base import Index
148
148
if categories is not None :
149
- categories = Index (categories )
149
+ categories = Index (categories , tupleize_cols = False )
150
150
# validation
151
151
cls ._validate_categories (categories , fastpath = fastpath )
152
152
cls ._validate_ordered (ordered )
@@ -211,8 +211,18 @@ def __repr__(self):
211
211
212
212
@staticmethod
213
213
def _hash_categories (categories , ordered = True ):
214
- from pandas .core .util .hashing import hash_array , _combine_hash_arrays
215
- cat_array = hash_array (np .asarray (categories ), categorize = False )
214
+ from pandas .core .util .hashing import (
215
+ hash_array , _combine_hash_arrays , hash_tuples
216
+ )
217
+
218
+ categories = np .asarray (categories )
219
+ if len (categories ) and isinstance (categories [0 ], tuple ):
220
+ # assumes if any individual category is a tuple, then all our. ATM
221
+ # I don't really want to support just some of the categories being
222
+ # tuples.
223
+ cat_array = hash_tuples (categories )
224
+ else :
225
+ cat_array = hash_array (np .asarray (categories ), categorize = False )
216
226
if ordered :
217
227
cat_array = np .vstack ([
218
228
cat_array , np .arange (len (cat_array ), dtype = cat_array .dtype )
0 commit comments