@@ -535,7 +535,6 @@ def _generate(cls, start, end, periods, name, freq,
535
535
freq = freq , name = name )
536
536
else :
537
537
index = _generate_regular_range (start , end , periods , freq )
538
-
539
538
else :
540
539
541
540
if tz is not None :
@@ -559,12 +558,13 @@ def _generate(cls, start, end, periods, name, freq,
559
558
freq = freq , name = name )
560
559
else :
561
560
index = _generate_regular_range (start , end , periods , freq )
562
-
563
561
if tz is not None and getattr (index , 'tz' , None ) is None :
564
- index = conversion .tz_localize_to_utc (_ensure_int64 (index ),
565
- tz ,
566
- ambiguous = ambiguous )
567
- index = index .view (_NS_DTYPE )
562
+ arr = conversion .tz_localize_to_utc (_ensure_int64 (index ),
563
+ tz ,
564
+ ambiguous = ambiguous )
565
+
566
+ arr = arr .view (_NS_DTYPE )
567
+ index = DatetimeIndex (arr )
568
568
569
569
# index is localized datetime64 array -> have to convert
570
570
# start/end as well to compare
@@ -585,7 +585,9 @@ def _generate(cls, start, end, periods, name, freq,
585
585
index = index [1 :]
586
586
if not right_closed and len (index ) and index [- 1 ] == end :
587
587
index = index [:- 1 ]
588
- index = cls ._simple_new (index , name = name , freq = freq , tz = tz )
588
+
589
+ index = cls ._simple_new (index .values , name = name , freq = freq , tz = tz )
590
+
589
591
return index
590
592
591
593
@property
@@ -619,9 +621,6 @@ def _simple_new(cls, values, name=None, freq=None, tz=None,
619
621
if we are passed a non-dtype compat, then coerce using the constructor
620
622
"""
621
623
622
- if isinstance (values , DatetimeIndex ):
623
- values = values .values
624
-
625
624
if getattr (values , 'dtype' , None ) is None :
626
625
# empty, but with dtype compat
627
626
if values is None :
0 commit comments