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