@@ -549,7 +549,6 @@ def _generate(cls, start, end, periods, name, freq,
549
549
freq = freq , name = name )
550
550
else :
551
551
index = _generate_regular_range (start , end , periods , freq )
552
-
553
552
else :
554
553
555
554
if tz is not None :
@@ -573,12 +572,13 @@ def _generate(cls, start, end, periods, name, freq,
573
572
freq = freq , name = name )
574
573
else :
575
574
index = _generate_regular_range (start , end , periods , freq )
576
-
577
575
if tz is not None and getattr (index , 'tz' , None ) is None :
578
- index = conversion .tz_localize_to_utc (_ensure_int64 (index ),
579
- tz ,
580
- ambiguous = ambiguous )
581
- index = index .view (_NS_DTYPE )
576
+ arr = conversion .tz_localize_to_utc (_ensure_int64 (index ),
577
+ tz ,
578
+ ambiguous = ambiguous )
579
+
580
+ arr = arr .view (_NS_DTYPE )
581
+ index = DatetimeIndex (arr )
582
582
583
583
# index is localized datetime64 array -> have to convert
584
584
# start/end as well to compare
@@ -596,7 +596,9 @@ def _generate(cls, start, end, periods, name, freq,
596
596
index = index [1 :]
597
597
if not right_closed and len (index ) and index [- 1 ] == end :
598
598
index = index [:- 1 ]
599
- index = cls ._simple_new (index , name = name , freq = freq , tz = tz )
599
+
600
+ index = cls ._simple_new (index .values , name = name , freq = freq , tz = tz )
601
+
600
602
return index
601
603
602
604
@property
@@ -630,9 +632,6 @@ def _simple_new(cls, values, name=None, freq=None, tz=None,
630
632
if we are passed a non-dtype compat, then coerce using the constructor
631
633
"""
632
634
633
- if isinstance (values , DatetimeIndex ):
634
- values = values .values
635
-
636
635
if getattr (values , 'dtype' , None ) is None :
637
636
# empty, but with dtype compat
638
637
if values is None :
0 commit comments