@@ -324,7 +324,9 @@ def _format_attrs(self):
324
324
"categories" ,
325
325
ibase .default_pprint (self .categories , max_seq_items = max_categories ),
326
326
),
327
- ("ordered" , self .ordered ),
327
+ # pandas\core\indexes\category.py:315: error: "CategoricalIndex"
328
+ # has no attribute "ordered" [attr-defined]
329
+ ("ordered" , self .ordered ), # type: ignore[attr-defined]
328
330
]
329
331
if self .name is not None :
330
332
attrs .append (("name" , ibase .default_pprint (self .name )))
@@ -659,6 +661,14 @@ def map(self, mapper):
659
661
660
662
def _concat (self , to_concat : List ["Index" ], name : Label ) -> "CategoricalIndex" :
661
663
# if calling index is category, don't check dtype of others
664
+ count = 0
665
+ for c in to_concat :
666
+ if not to_concat [0 ].ordered :
667
+ if count != 0 :
668
+ to_concat [count ] = CategoricalIndex (
669
+ list (to_concat [count ].values ), list (to_concat [0 ].categories ))
670
+ # c.categories = ['a', 'b']
671
+ count += 1
662
672
codes = np .concatenate ([self ._is_dtype_compat (c ).codes for c in to_concat ])
663
673
cat = self ._data ._from_backing_data (codes )
664
674
return type (self )._simple_new (cat , name = name )
0 commit comments