Skip to content

Commit f1fbe8c

Browse files
jbrockmendeljreback
authored andcommitted
CLN: remove redundant Index checks (#30195)
1 parent 45a8a68 commit f1fbe8c

File tree

1 file changed

+0
-14
lines changed

1 file changed

+0
-14
lines changed

pandas/core/indexes/base.py

-14
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,6 @@
4545
is_signed_integer_dtype,
4646
is_timedelta64_dtype,
4747
is_unsigned_integer_dtype,
48-
pandas_dtype,
4948
)
5049
from pandas.core.dtypes.concat import concat_compat
5150
from pandas.core.dtypes.generic import (
@@ -732,24 +731,11 @@ def astype(self, dtype, copy=True):
732731
from .category import CategoricalIndex
733732

734733
return CategoricalIndex(self.values, name=self.name, dtype=dtype, copy=copy)
735-
elif is_datetime64tz_dtype(dtype):
736-
# TODO(GH-24559): Remove this block, use the following elif.
737-
# avoid FutureWarning from DatetimeIndex constructor.
738-
from pandas import DatetimeIndex
739-
740-
tz = pandas_dtype(dtype).tz
741-
return DatetimeIndex(np.asarray(self)).tz_localize("UTC").tz_convert(tz)
742734

743735
elif is_extension_array_dtype(dtype):
744736
return Index(np.asarray(self), dtype=dtype, copy=copy)
745737

746738
try:
747-
if is_datetime64tz_dtype(dtype):
748-
from pandas import DatetimeIndex
749-
750-
return DatetimeIndex(
751-
self.values, name=self.name, dtype=dtype, copy=copy
752-
)
753739
return Index(
754740
self.values.astype(dtype, copy=copy), name=self.name, dtype=dtype
755741
)

0 commit comments

Comments
 (0)