Skip to content

Commit 556a0e6

Browse files
author
analyticalmonk
committed
Replace _coerce_to_dtype() with pandas_dtype()
Changes made to series.py, generic.py in pandas/core and cast.py in pandas/core/dtypes
1 parent 6aae97d commit 556a0e6

File tree

3 files changed

+5
-4
lines changed

3 files changed

+5
-4
lines changed

pandas/core/dtypes/cast.py

+2-1
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
is_number,
2424
_string_dtypes,
2525
_coerce_to_dtype,
26+
pandas_dtype,
2627
_ensure_int8, _ensure_int16,
2728
_ensure_int32, _ensure_int64,
2829
_NS_DTYPE, _TD_DTYPE, _INT64_DTYPE,
@@ -579,7 +580,7 @@ def astype_nansafe(arr, dtype, copy=True):
579580
""" return a view if copy is False, but
580581
need to be very careful as the result shape could change! """
581582
if not isinstance(dtype, np.dtype):
582-
dtype = _coerce_to_dtype(dtype)
583+
dtype = pandas_dtype(dtype)
583584

584585
if issubclass(dtype.type, text_type):
585586
# in Py3 that's str, in Py2 that's unicode

pandas/core/generic.py

-1
Original file line numberDiff line numberDiff line change
@@ -165,7 +165,6 @@ def _validate_dtype(self, dtype):
165165
""" validate the passed dtype """
166166

167167
if dtype is not None:
168-
dtype = _coerce_to_dtype(dtype)
169168
# This would raise an error if an invalid dtype was passed
170169
dtype = pandas_dtype(dtype)
171170

pandas/core/series.py

+3-2
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,8 @@
2828
is_dict_like,
2929
is_scalar,
3030
_is_unorderable_exception,
31-
_ensure_platform_int)
31+
_ensure_platform_int,
32+
pandas_dtype)
3233
from pandas.core.dtypes.generic import ABCSparseArray, ABCDataFrame
3334
from pandas.core.dtypes.cast import (
3435
maybe_upcast, infer_dtype_from_scalar,
@@ -2869,7 +2870,7 @@ def _sanitize_array(data, index, dtype=None, copy=False,
28692870
"""
28702871

28712872
if dtype is not None:
2872-
dtype = _coerce_to_dtype(dtype)
2873+
dtype = pandas_dtype(dtype)
28732874

28742875
if isinstance(data, ma.MaskedArray):
28752876
mask = ma.getmaskarray(data)

0 commit comments

Comments
 (0)