Skip to content

Commit 9c34762

Browse files
committed
Move to maybe_downcast_to_dtype
1 parent 98dd50f commit 9c34762

File tree

3 files changed

+5
-2
lines changed

3 files changed

+5
-2
lines changed

doc/source/whatsnew/v3.0.0.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -611,6 +611,7 @@ Categorical
611611
Datetimelike
612612
^^^^^^^^^^^^
613613
- Bug in :attr:`is_year_start` where a DateTimeIndex constructed via a date_range with frequency 'MS' wouldn't have the correct year or quarter start attributes (:issue:`57377`)
614+
- Bug in :class:`DataFrame` raising ``ValueError`` when ``dtype`` is ``timedelta64`` and ``data`` is a list containing ``None`` (:issue:`60064`)
614615
- Bug in :class:`Timestamp` constructor failing to raise when ``tz=None`` is explicitly specified in conjunction with timezone-aware ``tzinfo`` or data (:issue:`48688`)
615616
- Bug in :func:`date_range` where the last valid timestamp would sometimes not be produced (:issue:`56134`)
616617
- Bug in :func:`date_range` where using a negative frequency value would not include all points between the start and end values (:issue:`56147`)
@@ -758,7 +759,6 @@ Styler
758759

759760
Other
760761
^^^^^
761-
- Bug in :class:`DataFrame` raising ``ValueError`` when ``dtype`` is ``timedelta64`` and ``data`` is a list containing ``None`` (:issue:`60064`)
762762
- Bug in :class:`DataFrame` when passing a ``dict`` with a NA scalar and ``columns`` that would always return ``np.nan`` (:issue:`57205`)
763763
- Bug in :func:`eval` on :class:`ExtensionArray` on including division ``/`` failed with a ``TypeError``. (:issue:`58748`)
764764
- Bug in :func:`eval` where the names of the :class:`Series` were not preserved when using ``engine="numexpr"``. (:issue:`10239`)

pandas/core/arrays/timedeltas.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1111,7 +1111,7 @@ def sequence_to_td64ns(
11111111
else:
11121112
mask = np.isnan(data)
11131113

1114-
data = cast_from_unit_vectorized(data.ravel(), unit or "ns").reshape(data.shape)
1114+
data = cast_from_unit_vectorized(data, unit or "ns")
11151115
data[mask] = iNaT
11161116
data = data.view("m8[ns]")
11171117
copy = False

pandas/core/dtypes/cast.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1225,6 +1225,9 @@ def maybe_cast_to_datetime(
12251225
_ensure_nanosecond_dtype(dtype)
12261226

12271227
if lib.is_np_dtype(dtype, "m"):
1228+
if getattr(value, "ndim", 1) == 2 and value.shape[1] == 1:
1229+
res = TimedeltaArray._from_sequence(value.ravel(), dtype=dtype)
1230+
return res.reshape(value.shape)
12281231
res = TimedeltaArray._from_sequence(value, dtype=dtype)
12291232
return res
12301233
else:

0 commit comments

Comments
 (0)