Skip to content

Commit 04efd45

Browse files
committed
sidestep int sign/size astype issues
1 parent 207ffb9 commit 04efd45

File tree

1 file changed

+2
-9
lines changed

1 file changed

+2
-9
lines changed

pandas/core/indexes/datetimelike.py

+2-9
Original file line numberDiff line numberDiff line change
@@ -557,17 +557,10 @@ def astype(self, dtype, copy=True):
557557

558558
new_values = self._eadata.astype(dtype, copy=copy)
559559

560-
# we pass `dtype` to the Index constructor, for cases like
561-
# dtype=object to disable inference. But, DTA.astype ignores
562-
# integer sign and size, so we need to detect that case and
563-
# just choose int64.
564-
dtype = pandas_dtype(dtype)
565-
if is_integer_dtype(dtype):
566-
dtype = np.dtype("int64")
567-
568560
# pass copy=False because any copying will be done in the
569561
# _eadata.astype call above
570-
return Index(new_values, dtype=dtype, name=self.name, copy=False)
562+
return Index(new_values,
563+
dtype=new_values.dtype, name=self.name, copy=False)
571564

572565
@Appender(DatetimeLikeArrayMixin._time_shift.__doc__)
573566
def _time_shift(self, periods, freq=None):

0 commit comments

Comments
 (0)