From 331f4f92ef8277675bc5ee3601b7220d979e9c50 Mon Sep 17 00:00:00 2001 From: fjetter Date: Tue, 18 Sep 2018 15:22:26 +0200 Subject: [PATCH] BUG: fix numpy deprecation warning for scalar datetime64 values --- doc/source/whatsnew/v0.24.0.txt | 1 + pandas/core/dtypes/cast.py | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/doc/source/whatsnew/v0.24.0.txt b/doc/source/whatsnew/v0.24.0.txt index 30745f186edcc..559b2d8eda588 100644 --- a/doc/source/whatsnew/v0.24.0.txt +++ b/doc/source/whatsnew/v0.24.0.txt @@ -803,6 +803,7 @@ Other - Require at least 0.28.2 version of ``cython`` to support read-only memoryviews (:issue:`21688`) - :meth:`~pandas.io.formats.style.Styler.background_gradient` now also supports tablewise application (in addition to rowwise and columnwise) with ``axis=None`` (:issue:`15204`) - :meth:`~pandas.io.formats.style.Styler.bar` now also supports tablewise application (in addition to rowwise and columnwise) with ``axis=None`` and setting clipping range with ``vmin`` and ``vmax``. ``NaN`` values are also handled properly. (:issue:`21548`, :issue:`21526`) +- Constructing a Series with a numpy.datetime64 value will no longer issue a DeprecationWarning (:issue:`22741`) - - - diff --git a/pandas/core/dtypes/cast.py b/pandas/core/dtypes/cast.py index 410e061c895db..fc3ee955b62fc 100644 --- a/pandas/core/dtypes/cast.py +++ b/pandas/core/dtypes/cast.py @@ -1042,7 +1042,7 @@ def maybe_cast_to_datetime(value, dtype, errors='raise'): "dtype [{dtype}]".format(dtype=dtype)) if is_scalar(value): - if value == iNaT or isna(value): + if np.asscalar(value) == iNaT or isna(value): value = iNaT else: value = np.array(value, copy=False)