@@ -861,7 +861,7 @@ def append(self, other):
861
861
to_concat = self ._ensure_compat_concat (to_concat )
862
862
to_concat , factory = _process_concat_data (to_concat , name )
863
863
864
- return factory (com . _concat_compat ( to_concat ) )
864
+ return factory (to_concat )
865
865
866
866
def join (self , other , how = 'left' , level = None , return_indexers = False ):
867
867
"""
@@ -1636,29 +1636,50 @@ def _time_to_micros(time):
1636
1636
def _process_concat_data (to_concat , name ):
1637
1637
klass = Index
1638
1638
kwargs = {}
1639
+ concat = np .concatenate
1639
1640
1640
1641
all_dti = True
1641
1642
need_utc_convert = False
1643
+ has_naive = False
1642
1644
tz = None
1645
+
1643
1646
for x in to_concat :
1644
1647
if not isinstance (x , DatetimeIndex ):
1645
1648
all_dti = False
1646
1649
else :
1647
1650
if tz is None :
1648
1651
tz = x .tz
1649
- elif x .tz != tz :
1652
+
1653
+ if x .tz is None :
1654
+ has_naive = True
1655
+
1656
+ if x .tz != tz :
1650
1657
need_utc_convert = True
1651
1658
tz = 'UTC'
1652
1659
1653
- if need_utc_convert :
1654
- to_concat = [x .tz_convert ('UTC' ) for x in to_concat ]
1655
-
1656
1660
if all_dti :
1657
- klass = DatetimeIndex
1658
- kwargs = {'tz' : tz }
1661
+ need_obj_convert = False
1662
+ if has_naive and tz is not None :
1663
+ need_obj_convert = True
1664
+
1665
+ if need_obj_convert :
1666
+ to_concat = [x .asobject .values for x in to_concat ]
1659
1667
1660
- to_concat = [x .values if isinstance (x , Index ) else x
1661
- for x in to_concat ]
1668
+ else :
1669
+ if need_utc_convert :
1670
+ to_concat = [x .tz_convert ('UTC' ).values for x in to_concat ]
1671
+ else :
1672
+ to_concat = [x .values for x in to_concat ]
1673
+
1674
+ klass = DatetimeIndex
1675
+ kwargs = {'tz' : tz }
1676
+ concat = com ._concat_compat
1677
+ else :
1678
+ for i , x in enumerate (to_concat ):
1679
+ if isinstance (x , DatetimeIndex ):
1680
+ to_concat [i ] = x .asobject .values
1681
+ elif isinstance (x , Index ):
1682
+ to_concat [i ] = x .values
1662
1683
1663
- factory_func = lambda x : klass (x , name = name , ** kwargs )
1684
+ factory_func = lambda x : klass (concat ( x ) , name = name , ** kwargs )
1664
1685
return to_concat , factory_func
0 commit comments