File tree 2 files changed +40
-3
lines changed
2 files changed +40
-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,49 @@ cdef class _Period(PeriodMixin):
2038
2038
"""
2039
2039
Return the year this Period falls on.
2040
2040
2041
+ Returns
2042
+ -------
2043
+ int
2044
+ The year (e.g., 2023)
2045
+
2046
+ See Also
2047
+ --------
2048
+ period.month : Get the month of the year on the given Period.
2049
+ period.day : Return the day of the month the Period falls on.
2050
+
2051
+ Notes
2052
+ -----
2053
+ The year is based on the `ordinal` and `base` attributes of the Period.
2054
+
2041
2055
Examples
2042
2056
--------
2043
- >>> period = pd.Period(' 2022-01' , ' M' )
2057
+ Create a Period object for January 2023 and get the year:
2058
+
2059
+ >>> period = pd.Period(' 2023-01' , ' M' )
2044
2060
>>> period.year
2045
- 2022
2061
+ 2023
2062
+
2063
+ Create a Period object for 01 January 2023 and get the year:
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.month
2078
+ nan
2079
+
2080
+ Period object with an invalid format:
2081
+
2082
+ >>> period = pd.Period(' invalid' , ' M' )
2083
+ # Will raise an DateParseError
2046
2084
"""
2047
2085
base = self ._dtype._dtype_code
2048
2086
return pyear(self.ordinal , base )
You can’t perform that action at this time.
0 commit comments