File tree 2 files changed +29
-6
lines changed
2 files changed +29
-6
lines changed Original file line number Diff line number Diff line change @@ -491,3 +491,30 @@ def convert_sparse(x, axis):
491
491
# coerce to object if needed
492
492
result = result .astype ('object' )
493
493
return result
494
+
495
+
496
+ def _concat_indexes (to_concat , default = None ):
497
+ """
498
+ Concatenate elements of to_concat to single Index
499
+
500
+ Parameters
501
+ ----------
502
+ to_concat : list-like of indexes
503
+ default : Index subclass to use if "to_concat" is empty, or None
504
+
505
+ Returns
506
+ -------
507
+ a single index, preserving the combined dtypes
508
+ """
509
+
510
+ if len (to_concat ) == 0 :
511
+ if default is None :
512
+ raise ValueError ("_concat_indexes called with empty \" to_concat\" "
513
+ "and default=None" )
514
+ return default ([])
515
+
516
+ typs = get_dtype_kinds (to_concat )
517
+ if len (typs ) == 1 :
518
+ return to_concat [0 ].__class__ ._concat_same_dtype (to_concat )
519
+ else :
520
+ return _concat_index_asobject (to_concat )
Original file line number Diff line number Diff line change @@ -1686,15 +1686,11 @@ def append(self, other):
1686
1686
return res
1687
1687
1688
1688
@classmethod
1689
- def _concat (self , to_concat ):
1689
+ def _concat (cls , to_concat ):
1690
1690
"""
1691
1691
Concatenate to_concat to single Index
1692
1692
"""
1693
- typs = _concat .get_dtype_kinds (to_concat )
1694
- if len (typs ) == 1 :
1695
- return self ._concat_same_dtype (to_concat )
1696
- else :
1697
- return _concat ._concat_index_asobject (to_concat )
1693
+ return _concat ._concat_indexes (to_concat , default = cls )
1698
1694
1699
1695
@classmethod
1700
1696
def _concat_same_dtype (cls , to_concat ):
You can’t perform that action at this time.
0 commit comments