Skip to content

Commit 914b0e8

Browse files
committed
Added some PeriodIndex examples
1 parent a1f050a commit 914b0e8

File tree

1 file changed

+18
-0
lines changed

1 file changed

+18
-0
lines changed

pandas/core/arrays/period.py

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -468,6 +468,12 @@ def __arrow_array__(self, type=None):
468468
"day_of_week",
469469
"""
470470
The day of the week with Monday=0, Sunday=6.
471+
472+
Examples
473+
--------
474+
>>> idx = pd.PeriodIndex(["2023-01-01", "2023-01-02", "2023-01-03"], freq="D")
475+
>>> idx.day_of_week
476+
Index([6, 0, 1], dtype='int64')
471477
""",
472478
)
473479
dayofweek = day_of_week
@@ -476,6 +482,18 @@ def __arrow_array__(self, type=None):
476482
"day_of_year",
477483
"""
478484
The ordinal day of the year.
485+
486+
Examples
487+
--------
488+
>>> idx = pd.PeriodIndex(["2023-01-10", "2023-02-01", "2023-03-01"], freq="D")
489+
>>> idx.dayofyear
490+
Index([10, 32, 60], dtype='int64')
491+
492+
>>> idx = pd.PeriodIndex(["2023", "2024", "2025"], freq="Y")
493+
>>> idx
494+
PeriodIndex(['2023', '2024', '2025'], dtype='period[A-DEC]')
495+
>>> idx.dayofyear
496+
Index([365, 366, 365], dtype='int64')
479497
""",
480498
)
481499
quarter = _field_accessor(

0 commit comments

Comments
 (0)