From 5c18c8ab5445943b9cdec2efc3e189c683d45dbb Mon Sep 17 00:00:00 2001 From: Natalia Mokeeva Date: Tue, 22 Aug 2023 23:57:04 +0200 Subject: [PATCH] fix example in whatsnew/v0.13.0.rst --- doc/source/whatsnew/v0.13.0.rst | 37 ++++++++++++++++++++++++++++----- 1 file changed, 32 insertions(+), 5 deletions(-) diff --git a/doc/source/whatsnew/v0.13.0.rst b/doc/source/whatsnew/v0.13.0.rst index c60a821968c0c..540e1d23814ff 100644 --- a/doc/source/whatsnew/v0.13.0.rst +++ b/doc/source/whatsnew/v0.13.0.rst @@ -537,7 +537,6 @@ Enhancements is frequency conversion. See :ref:`the docs` for the docs. .. ipython:: python - :okexcept: import datetime td = pd.Series(pd.date_range('20130101', periods=4)) - pd.Series( @@ -546,13 +545,41 @@ Enhancements td[3] = np.nan td + .. code-block:: ipython + # to days - td / np.timedelta64(1, 'D') - td.astype('timedelta64[D]') + In [63]: td / np.timedelta64(1, 'D') + Out[63]: + 0 31.000000 + 1 31.000000 + 2 31.003507 + 3 NaN + dtype: float64 + + In [64]: td.astype('timedelta64[D]') + Out[64]: + 0 31.0 + 1 31.0 + 2 31.0 + 3 NaN + dtype: float64 # to seconds - td / np.timedelta64(1, 's') - td.astype('timedelta64[s]') + In [65]: td / np.timedelta64(1, 's') + Out[65]: + 0 2678400.0 + 1 2678400.0 + 2 2678703.0 + 3 NaN + dtype: float64 + + In [66]: td.astype('timedelta64[s]') + Out[66]: + 0 2678400.0 + 1 2678400.0 + 2 2678703.0 + 3 NaN + dtype: float64 Dividing or multiplying a ``timedelta64[ns]`` Series by an integer or integer Series