@@ -525,7 +525,6 @@ def _generate(cls, start, end, periods, name, freq,
525
525
freq = freq , name = name )
526
526
else :
527
527
index = _generate_regular_range (start , end , periods , freq )
528
-
529
528
else :
530
529
531
530
if tz is not None :
@@ -549,12 +548,13 @@ def _generate(cls, start, end, periods, name, freq,
549
548
freq = freq , name = name )
550
549
else :
551
550
index = _generate_regular_range (start , end , periods , freq )
552
-
553
551
if tz is not None and getattr (index , 'tz' , None ) is None :
554
- index = conversion .tz_localize_to_utc (_ensure_int64 (index ),
555
- tz ,
556
- ambiguous = ambiguous )
557
- index = index .view (_NS_DTYPE )
552
+ arr = conversion .tz_localize_to_utc (_ensure_int64 (index ),
553
+ tz ,
554
+ ambiguous = ambiguous )
555
+
556
+ arr = arr .view (_NS_DTYPE )
557
+ index = DatetimeIndex (arr )
558
558
559
559
# index is localized datetime64 array -> have to convert
560
560
# start/end as well to compare
@@ -575,7 +575,9 @@ def _generate(cls, start, end, periods, name, freq,
575
575
index = index [1 :]
576
576
if not right_closed and len (index ) and index [- 1 ] == end :
577
577
index = index [:- 1 ]
578
- index = cls ._simple_new (index , name = name , freq = freq , tz = tz )
578
+
579
+ index = cls ._simple_new (index .values , name = name , freq = freq , tz = tz )
580
+
579
581
return index
580
582
581
583
def _convert_for_op (self , value ):
@@ -598,9 +600,6 @@ def _simple_new(cls, values, name=None, freq=None, tz=None,
598
600
if we are passed a non-dtype compat, then coerce using the constructor
599
601
"""
600
602
601
- if isinstance (values , DatetimeIndex ):
602
- values = values .values
603
-
604
603
if getattr (values , 'dtype' , None ) is None :
605
604
# empty, but with dtype compat
606
605
if values is None :
0 commit comments