From 279fdf6b2c339ed1fc4e75e7ccafa9fa55ed7a72 Mon Sep 17 00:00:00 2001 From: sinhrks Date: Thu, 19 Jan 2017 08:29:51 +0900 Subject: [PATCH] remove import failure --- doc/source/whatsnew/v0.20.0.txt | 1 + pandas/core/internals.py | 4 ++-- pandas/types/cast.py | 2 +- 3 files changed, 4 insertions(+), 3 deletions(-) diff --git a/doc/source/whatsnew/v0.20.0.txt b/doc/source/whatsnew/v0.20.0.txt index 798151971363e..16efdbaf2bf76 100644 --- a/doc/source/whatsnew/v0.20.0.txt +++ b/doc/source/whatsnew/v0.20.0.txt @@ -384,6 +384,7 @@ Bug Fixes - Bug in ``pd.read_msgpack()`` in which ``Series`` categoricals were being improperly processed (:issue:`14901`) - Bug in ``Series.ffill()`` with mixed dtypes containing tz-aware datetimes. (:issue:`14956`) +- Bug in ``.replace()`` may result in incorrect dtypes. (:issue:`12747`) diff --git a/pandas/core/internals.py b/pandas/core/internals.py index ff1357644ab8c..5c9b67e9c28ad 100644 --- a/pandas/core/internals.py +++ b/pandas/core/internals.py @@ -3236,7 +3236,7 @@ def comp(s): return _possibly_compare(values, getattr(s, 'asm8', s), operator.eq) - def _cast(block, scalar): + def _cast_scalar(block, scalar): dtype, val = _infer_dtype_from_scalar(scalar, pandas_dtype=True) if not is_dtype_equal(block.dtype, dtype): dtype = _find_common_type([block.dtype, dtype]) @@ -3268,7 +3268,7 @@ def _cast(block, scalar): # particular block m = masks[i][b.mgr_locs.indexer] if m.any(): - b, val = _cast(b, d) + b, val = _cast_scalar(b, d) new_rb.extend(b.putmask(m, val, inplace=True)) else: new_rb.append(b) diff --git a/pandas/types/cast.py b/pandas/types/cast.py index 31fb9293e124a..cd3f3a2bf5a96 100644 --- a/pandas/types/cast.py +++ b/pandas/types/cast.py @@ -19,7 +19,7 @@ _ensure_int8, _ensure_int16, _ensure_int32, _ensure_int64, _NS_DTYPE, _TD_DTYPE, _INT64_DTYPE, - _DATELIKE_DTYPES, _POSSIBLY_CAST_DTYPES) + _POSSIBLY_CAST_DTYPES) from .dtypes import ExtensionDtype, DatetimeTZDtype, PeriodDtype from .generic import ABCDatetimeIndex, ABCPeriodIndex, ABCSeries from .missing import isnull, notnull