File tree 2 files changed +35
-3
lines changed
2 files changed +35
-3
lines changed Original file line number Diff line number Diff line change @@ -79,7 +79,6 @@ if [[ -z "$CHECK" || "$CHECK" == "docstrings" ]]; then
79
79
-i " pandas.Period.ordinal GL08" \
80
80
-i " pandas.Period.strftime PR01,SA01" \
81
81
-i " pandas.Period.to_timestamp SA01" \
82
- -i " pandas.Period.year SA01" \
83
82
-i " pandas.PeriodDtype SA01" \
84
83
-i " pandas.PeriodDtype.freq SA01" \
85
84
-i " pandas.PeriodIndex.day SA01" \
Original file line number Diff line number Diff line change @@ -2038,11 +2038,44 @@ cdef class _Period(PeriodMixin):
2038
2038
"""
2039
2039
Return the year this Period falls on.
2040
2040
2041
+ Returns
2042
+ -------
2043
+ int
2044
+
2045
+ See Also
2046
+ --------
2047
+ period.month : Get the month of the year for the given Period.
2048
+ period.day : Return the day of the month the Period falls on.
2049
+
2050
+ Notes
2051
+ -----
2052
+ The year is based on the `ordinal` and `base` attributes of the Period.
2053
+
2041
2054
Examples
2042
2055
--------
2043
- >>> period = pd.Period(' 2022-01' , ' M' )
2056
+ Create a Period object for January 2023 and get the year:
2057
+
2058
+ >>> period = pd.Period(' 2023-01' , ' M' )
2044
2059
>>> period.year
2045
- 2022
2060
+ 2023
2061
+
2062
+ Create a Period object for 01 January 2023 and get the year:
2063
+
2064
+ >>> period = pd.Period(' 2023' , ' D' )
2065
+ >>> period.year
2066
+ 2023
2067
+
2068
+ Get the year for a period representing a quarter:
2069
+
2070
+ >>> period = pd.Period(' 2023Q2' , ' Q' )
2071
+ >>> period.year
2072
+ 2023
2073
+
2074
+ Handle a case where the Period object is empty , which results in `NaN`:
2075
+
2076
+ >>> period = pd.Period(' nan' , ' M' )
2077
+ >>> period.year
2078
+ nan
2046
2079
"""
2047
2080
base = self ._dtype._dtype_code
2048
2081
return pyear(self.ordinal , base )
You can’t perform that action at this time.
0 commit comments