Skip to content

Commit 253d26a

Browse files
authored
DOC: Remove use of as_type for PeriodIndex to DatetimeIndex conversion (#44447)
1 parent 847e8ba commit 253d26a

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

doc/source/user_guide/timeseries.rst

+7-3
Original file line numberDiff line numberDiff line change
@@ -2073,14 +2073,18 @@ The ``period`` dtype can be used in ``.astype(...)``. It allows one to change th
20732073
# change monthly freq to daily freq
20742074
pi.astype("period[D]")
20752075
2076-
# convert to DatetimeIndex
2077-
pi.astype("datetime64[ns]")
2078-
20792076
# convert to PeriodIndex
20802077
dti = pd.date_range("2011-01-01", freq="M", periods=3)
20812078
dti
20822079
dti.astype("period[M]")
20832080
2081+
.. deprecated:: 1.4.0
2082+
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.
2083+
2084+
.. ipython:: python
2085+
2086+
# convert to DatetimeIndex
2087+
pi.to_timestamp(how="start")
20842088
20852089
PeriodIndex partial string indexing
20862090
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

0 commit comments

Comments
 (0)