diff --git a/doc/source/whatsnew/v3.0.0.rst b/doc/source/whatsnew/v3.0.0.rst index a5b4560a47bc4..258a0c3a5e99b 100644 --- a/doc/source/whatsnew/v3.0.0.rst +++ b/doc/source/whatsnew/v3.0.0.rst @@ -58,6 +58,7 @@ Other enhancements - :meth:`pandas.concat` will raise a ``ValueError`` when ``ignore_index=True`` and ``keys`` is not ``None`` (:issue:`59274`) - :meth:`str.get_dummies` now accepts a ``dtype`` parameter to specify the dtype of the resulting DataFrame (:issue:`47872`) - Multiplying two :class:`DateOffset` objects will now raise a ``TypeError`` instead of a ``RecursionError`` (:issue:`59442`) +- Arithmetic operations on :class:`Datetime` dataframe and series objects will result in :class:`Timedelta` values instead of ``TypeError`` (:issue: `59529`) - Restore support for reading Stata 104-format and enable reading 103-format dta files (:issue:`58554`) - Support passing a :class:`Iterable[Hashable]` input to :meth:`DataFrame.drop_duplicates` (:issue:`59237`) - Support reading Stata 102-format (Stata 1) dta files (:issue:`58978`) diff --git a/pandas/core/internals/managers.py b/pandas/core/internals/managers.py index aa4a785519051..bc3a9325f8abb 100644 --- a/pandas/core/internals/managers.py +++ b/pandas/core/internals/managers.py @@ -997,6 +997,8 @@ def _make_na_block( dtype = interleaved_dtype([blk.dtype for blk in self.blocks]) if dtype is not None and np.issubdtype(dtype.type, np.floating): fill_value = dtype.type(fill_value) + if dtype is not None and np.issubdtype(dtype.type, np.datetime64): + fill_value = np.datetime64("NaT") shape = (len(placement), self.shape[1]) diff --git a/pandas/tests/frame/test_arithmetic.py b/pandas/tests/frame/test_arithmetic.py index e41a3b27e592c..5d861bdecd884 100644 --- a/pandas/tests/frame/test_arithmetic.py +++ b/pandas/tests/frame/test_arithmetic.py @@ -1038,9 +1038,9 @@ def test_frame_with_frame_reindex(self): [ (1, "i8"), (1.0, "f8"), - (2**63, "f8"), + (2 ** 63, "f8"), (1j, "complex128"), - (2**63, "complex128"), + (2 ** 63, "complex128"), (True, "bool"), (np.timedelta64(20, "ns"), "