8000 DEPR: Deprecate tshift and integrate it to shift by fujiaxiang · Pull Request #34545 · pandas-dev/pandas · GitHub
[go: up one dir, main page]

Skip to content

DEPR: Deprecate tshift and integrate it to shift #34545

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 8 commits into from
Jun 15, 2020
Prev Previous commit
Next Next commit
removed mention of tshift in timeseries user guide
  • Loading branch information
fujiaxiang committed Jun 3, 2020
commit a62b0ea42bd409ffb2efebf98114570d449f8d5b
20 changes: 8 additions & 12 deletions doc/source/user_guide/timeseries.rst
View file Open in desktop
Original file line number Diff line number Diff line change
Expand Up @@ -516,7 +516,7 @@ The ``DatetimeIndex`` class contains many time series related optimizations:
* A large range of dates for various offsets are pre-computed and cached
under the hood in order to make generating subsequent date ranges very fast
(just have to grab a slice).
* Fast shifting using the ``shift`` and ``tshift`` method on pandas objects.
* Fast shifting using the ``shift`` method on pandas objects.
* Unioning of overlapping ``DatetimeIndex`` objects with the same frequency is
very fast (important for fast data alignment).
* Quick access to date fields via properties such as ``year``, ``month``, etc.
Expand Down Expand Up @@ -1462,23 +1462,19 @@ the pandas objects.

The ``shift`` method accepts an ``freq`` argument which can accept a
``DateOffset`` class or other ``timedelta``-like object or also an
:ref:`offset alias <timeseries.offset_aliases>`:
:ref:`offset alias <timeseries.offset_aliases>`.

When ``freq`` is specified, ``shift`` method changes all the dates in the index
rather than changing the alignment of the data and the index:

.. ipython:: python

ts.shift(5, freq='D')
ts.shift(5, freq=pd.offsets.BDay())
ts.shift(5, freq='BM')

Rather than changing the alignment of the data and the index, ``DataFrame`` and
``Series`` objects also have a :meth:`~Series.tshift` convenience method that
changes all the dates in the index by a specified number of offsets:

.. ipython:: python

ts.tshift(5, freq='D')

Note that with ``tshift``, the leading entry is no longer NaN because the data
is not being realigned.
Note that with when ``freq`` is specified, the leading entry is no longer NaN
because the data is not being realigned.

Frequency conversion
~~~~~~~~~~~~~~~~~~~~
Expand Down
0