Skip to content

Commit 6896433

Browse files
committed
update for review
1 parent b2d8ad7 commit 6896433

File tree

4 files changed

+10
-5
lines changed

4 files changed

+10
-5
lines changed

doc/source/whatsnew/v0.21.0.txt

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -133,7 +133,8 @@ Dtype Conversions
133133
s[1] = True
134134
s
135135

136-
- Previously as assignment to a datetimelike with a non-datetimelike would corece (:issue:`14145`).
136+
- Previously as assignment to a datetimelike with a non-datetimelike would coerce the
137+
non-datetime-like item being assigned (:issue:`14145`).
137138

138139
.. ipython:: python
139140

@@ -206,7 +207,7 @@ Bug Fixes
206207
Conversion
207208
^^^^^^^^^^
208209

209-
- Bug in assignment against datetime-like data with ``int`` may incorrectly converted to datetime-like (:issue:`14145`)
210+
- Bug in assignment against datetime-like data with ``int`` may incorrectly converte to datetime-like (:issue:`14145`)
210211
- Bug in assignment against ``int64`` data with ``np.ndarray`` with ``float64`` dtype may keep ``int64`` dtype (:issue:`14001`)
211212

212213

pandas/core/dtypes/cast.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -445,6 +445,7 @@ def infer_dtype_from_array(arr, pandas_dtype=False):
445445
-----
446446
if pandas_dtype=False. these infer to numpy dtypes
447447
exactly with the exception that mixed / object dtypes
448+
are not coerced by stringifying or conversion
448449
449450
if pandas_dtype=True. datetime64tz-aware/categorical
450451
types will retain there character.
@@ -465,8 +466,7 @@ def infer_dtype_from_array(arr, pandas_dtype=False):
465466
if not is_list_like(arr):
466467
arr = [arr]
467468

468-
if pandas_dtype and (is_categorical_dtype(arr) or
469-
is_datetime64tz_dtype(arr)):
469+
if pandas_dtype and is_extension_type(arr):
470470
return arr.dtype, arr
471471

472472
elif isinstance(arr, ABCSeries):

pandas/core/dtypes/common.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
ExtensionDtype)
1212
from .generic import (ABCCategorical, ABCPeriodIndex,
1313
ABCDatetimeIndex, ABCSeries,
14-
ABCSparseArray, ABCSparseSeries, ABCCategoricalIndex
14+
ABCSparseArray, ABCSparseSeries, ABCCategoricalIndex,
1515
ABCIndexClass)
1616
from .inference import is_string_like
1717
from .inference import * # noqa

pandas/tests/dtypes/test_cast.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -163,6 +163,10 @@ def testinfer_dtype_from_scalar(self):
163163
dtype, val = infer_dtype_from_scalar(data)
164164
assert dtype == np.object_
165165

166+
def testinfer_dtype_from_scalar_errors(self):
167+
with pytest.raises(ValueError):
168+
infer_dtype_from_scalar(np.array([1]))
169+
166170
@pytest.mark.parametrize(
167171
"arr, expected, pandas_dtype",
168172
[('foo', np.object_, False),

0 commit comments

Comments
 (0)