@@ -261,6 +261,7 @@ def _scalar_type(self) -> type[Timestamp]:
261
261
)
262
262
_datetimelike_methods : list [str ] = [
263
263
"to_period" ,
264
+ "to_timestamp" ,
264
265
"tz_localize" ,
265
266
"tz_convert" ,
266
267
"normalize" ,
@@ -1271,6 +1272,51 @@ def to_period(self, freq=None) -> PeriodArray:
1271
1272
freq = res
1272
1273
return PeriodArray ._from_datetime64 (self ._ndarray , freq , tz = self .tz )
1273
1274
1275
+ def to_timestamp (self ):
1276
+ """
1277
+ Convert ``Series`` of ``Periods`` to ``DatetimeIndex/Array``.
1278
+
1279
+ This method converts a Series of Periods to a ``DatetimeIndex/Array``.
1280
+ The ``freq`` and ``how`` parameters cannot be used when calling
1281
+ ``to_timestamp`` the ``.dt`` accessor.
1282
+
1283
+ Returns
1284
+ -------
1285
+ DatetimeArray/Index
1286
+ A `DatetimeArray` or `DatetimeIndex` object representing the period
1287
+ converted to a timestamp.
1288
+
1289
+ See Also
1290
+ --------
1291
+ PeriodIndex.day : The days of the period.
1292
+ PeriodIndex.from_fields : Construct a PeriodIndex from fields
1293
+ (year, month, day, etc.).
1294
+ PeriodIndex.from_ordinals : Construct a PeriodIndex from ordinals.
1295
+ PeriodIndex.hour : The hour of the period.
1296
+ PeriodIndex.minute : The minute of the period.
1297
+ PeriodIndex.month : The month as January=1, December=12.
1298
+ PeriodIndex.second : The second of the period.
1299
+ PeriodIndex.year : The year of the period.
1300
+
1301
+ Examples
1302
+ --------
1303
+ >>> s = pd.Series(pd.period_range("2023-01", periods=3, freq="M"))
1304
+ >>> s
1305
+ 0 2023-01
1306
+ 1 2023-02
1307
+ 2 2023-03
1308
+ dtype: period[M]
1309
+ >>> s.dt.to_timestamp()
1310
+ 0 2023-01-01
1311
+ 1 2023-02-01
1312
+ 2 2023-03-01
1313
+ dtype: datetime64[ns]
1314
+ """
1315
+ # Call the to_timestamp function in PeriodArray() class, ignoring freq and how
1316
+ from pandas .core .arrays import PeriodArray
1317
+
1318
+ return PeriodArray (self ._data ).to_timestamp ()
1319
+
1274
1320
# -----------------------------------------------------------------
1275
1321
# Properties - Vectorized Timestamp Properties/Methods
1276
1322
0 commit comments