Skip to content

DOC: fix an example which raises an Error in v0.13.0.rst #54696

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Aug 23, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
37 changes: 32 additions & 5 deletions doc/source/whatsnew/v0.13.0.rst
Original file line number Diff line number Diff line change
Expand Up @@ -537,7 +537,6 @@ Enhancements
is frequency conversion. See :ref:`the docs<timedeltas.timedeltas_convert>` for the docs.

.. ipython:: python
:okexcept:

import datetime
td = pd.Series(pd.date_range('20130101', periods=4)) - pd.Series(
Expand All @@ -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

Expand Down