File tree 1 file changed +22
-0
lines changed
1 file changed +22
-0
lines changed Original file line number Diff line number Diff line change @@ -10503,6 +10503,28 @@ def to_period(
10503
10503
Returns
10504
10504
-------
10505
10505
DataFrame with PeriodIndex
10506
+
10507
+ Examples
10508
+ --------
10509
+ >>> idx = pd.to_datetime(
10510
+ ... [
10511
+ ... "2001-03-31 00:00:00",
10512
+ ... "2002-05-31 00:00:00",
10513
+ ... "2003-08-31 00:00:00",
10514
+ ... ]
10515
+ ... )
10516
+
10517
+ >>> idx
10518
+ DatetimeIndex(['2001-03-31', '2002-05-31', '2003-08-31'],
10519
+ dtype='datetime64[ns]', freq=None)
10520
+
10521
+ >>> idx.to_period("M")
10522
+ PeriodIndex(['2001-03', '2002-05', '2003-08'], dtype='period[M]')
10523
+
10524
+ For the yearly frequency
10525
+
10526
+ >>> idx.to_period("Y")
10527
+ PeriodIndex(['2001', '2002', '2003'], dtype='period[A-DEC]')
10506
10528
"""
10507
10529
new_obj = self .copy (deep = copy )
10508
10530
You can’t perform that action at this time.
0 commit comments