Skip to content

Commit 3700259

Browse files
CLN: 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 c10e1d4 commit 3700259

File tree

3 files changed

+6
-7
lines changed

3 files changed

+6
-7
lines changed

pandas/core/dtypes/cast.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
is_numeric_dtype, is_decimal,
2323
is_number,
2424
_string_dtypes,
25-
_coerce_to_dtype,
25+
pandas_dtype,
2626
_ensure_int8, _ensure_int16,
2727
_ensure_int32, _ensure_int64,
2828
_NS_DTYPE, _TD_DTYPE, _INT64_DTYPE,
@@ -579,7 +579,7 @@ def astype_nansafe(arr, dtype, copy=True):
579579
""" return a view if copy is False, but
580580
need to be very careful as the result shape could change! """
581581
if not isinstance(dtype, np.dtype):
582-
dtype = _coerce_to_dtype(dtype)
582+
dtype = pandas_dtype(dtype)
583583

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

pandas/core/generic.py

-2
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@
1111

1212
from pandas._libs import tslib, lib
1313
from pandas.core.dtypes.common import (
14-
_coerce_to_dtype,
1514
_ensure_int64,
1615
needs_i8_conversion,
1716
is_scalar,
@@ -165,7 +164,6 @@ def _validate_dtype(self, dtype):
165164
""" validate the passed dtype """
166165

167166
if dtype is not None:
168-
dtype = _coerce_to_dtype(dtype)
169167
# This would raise an error if an invalid dtype was passed
170168
dtype = pandas_dtype(dtype)
171169

pandas/core/series.py

+4-3
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
import numpy.ma as ma
1515

1616
from pandas.core.dtypes.common import (
17-
_coerce_to_dtype, is_categorical_dtype,
17+
is_categorical_dtype,
1818
is_bool,
1919
is_integer, is_integer_dtype,
2020
is_float_dtype,
@@ -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)