Skip to content

Commit

Permalink
DOC: fix an example which raises an Error in whatsnew/v0.24.0.rst (#5…
Browse files Browse the repository at this point in the history
…4738)

fix example in whatsnew/v0.24.0.rst
  • Loading branch information
natmokval authored Aug 25, 2023
1 parent 87b3bb5 commit 9aa40b9
Showing 1 changed file with 13 additions and 9 deletions.
22 changes: 13 additions & 9 deletions doc/source/whatsnew/v0.24.0.rst
Original file line number Diff line number Diff line change
Expand Up @@ -1377,18 +1377,22 @@ the object's ``freq`` attribute (:issue:`21939`, :issue:`23878`).
*New behavior*:

.. ipython:: python
:okexcept:
:okwarning:
.. code-block:: ipython
In [108]: ts = pd.Timestamp('1994-05-06 12:15:16', freq=pd.offsets.Hour())
In[109]: ts + 2 * ts.freq
Out[109]: Timestamp('1994-05-06 14:15:16', freq='H')
In [110]: tdi = pd.timedelta_range('1D', periods=2)
ts = pd.Timestamp('1994-05-06 12:15:16', freq=pd.offsets.Hour())
ts + 2 * ts.freq
In [111]: tdi - np.array([2 * tdi.freq, 1 * tdi.freq])
Out[111]: TimedeltaIndex(['-1 days', '1 days'], dtype='timedelta64[ns]', freq=None)
tdi = pd.timedelta_range('1D', periods=2)
tdi - np.array([2 * tdi.freq, 1 * tdi.freq])
In [112]: dti = pd.date_range('2001-01-01', periods=2, freq='7D')
dti = pd.date_range('2001-01-01', periods=2, freq='7D')
dti + pd.Index([1 * dti.freq, 2 * dti.freq])
In [113]: dti + pd.Index([1 * dti.freq, 2 * dti.freq])
Out[113]: DatetimeIndex(['2001-01-08', '2001-01-22'], dtype='datetime64[ns]', freq=None)
.. _whatsnew_0240.deprecations.integer_tz:
Expand Down

0 comments on commit 9aa40b9

Please sign in to comment.