Skip to content

DOC: Remove use of as_type for PeriodIndex to DatetimeIndex conversion #44447

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
Nov 14, 2021
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
10 changes: 7 additions & 3 deletions doc/source/user_guide/timeseries.rst
Original file line number Diff line number Diff line change
Expand Up @@ -2073,14 +2073,18 @@ The ``period`` dtype can be used in ``.astype(...)``. It allows one to change th
# change monthly freq to daily freq
pi.astype("period[D]")

# convert to DatetimeIndex
pi.astype("datetime64[ns]")

# convert to PeriodIndex
dti = pd.date_range("2011-01-01", freq="M", periods=3)
dti
dti.astype("period[M]")

.. deprecated:: 1.4.0
Converting PeriodIndex to DatetimeIndex with ``.astype(...)`` is deprecated and will raise in a future version. Use ``obj.to_timestamp(how).tz_localize(dtype.tz)`` instead.

.. ipython:: python

# convert to DatetimeIndex
pi.to_timestamp(how="start")

PeriodIndex partial string indexing
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Expand Down