Skip to content

Commit 331f4f9

Browse files
committed
BUG: fix numpy deprecation warning for scalar datetime64 values
1 parent c44581f commit 331f4f9

File tree

2 files changed

+2
-1
lines changed

2 files changed

+2
-1
lines changed

doc/source/whatsnew/v0.24.0.txt

+1
Original file line numberDiff line numberDiff line change
@@ -803,6 +803,7 @@ Other
803803
- Require at least 0.28.2 version of ``cython`` to support read-only memoryviews (:issue:`21688`)
804804
- :meth:`~pandas.io.formats.style.Styler.background_gradient` now also supports tablewise application (in addition to rowwise and columnwise) with ``axis=None`` (:issue:`15204`)
805805
- :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`)
806+
- Constructing a Series with a numpy.datetime64 value will no longer issue a DeprecationWarning (:issue:`22741`)
806807
-
807808
-
808809
-

pandas/core/dtypes/cast.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -1042,7 +1042,7 @@ def maybe_cast_to_datetime(value, dtype, errors='raise'):
10421042
"dtype [{dtype}]".format(dtype=dtype))
10431043

10441044
if is_scalar(value):
1045-
if value == iNaT or isna(value):
1045+
if np.asscalar(value) == iNaT or isna(value):
10461046
value = iNaT
10471047
else:
10481048
value = np.array(value, copy=False)

0 commit comments

Comments
 (0)