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