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