Skip to content

Commit 5918722

Browse files
committed
Fix docstrings for pandas.Period.asfreq SA01
1 parent cd57fa5 commit 5918722

File tree

2 files changed

+42
-6
lines changed

2 files changed

+42
-6
lines changed

ci/code_checks.sh

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,6 @@ if [[ -z "$CHECK" || "$CHECK" == "docstrings" ]]; then
7676
-i "pandas.MultiIndex.to_frame RT03" \
7777
-i "pandas.NA SA01" \
7878
-i "pandas.NaT SA01" \
79-
-i "pandas.Period.asfreq SA01" \
8079
-i "pandas.Period.freq GL08" \
8180
-i "pandas.Period.freqstr SA01" \
8281
-i "pandas.Period.ordinal GL08" \

pandas/_libs/tslibs/period.pyx

Lines changed: 42 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1913,20 +1913,57 @@ cdef class _Period(PeriodMixin):
19131913
Parameters
19141914
----------
19151915
freq : str, BaseOffset
1916-
The desired frequency. If passing a `str`, it needs to be a
1917-
valid :ref:`period alias <timeseries.period_aliases>`.
1916+
The target frequency to convert the Period object to. If a string is provided,
1917+
it must be a valid :ref:`period alias <timeseries.period_aliases>`.
1918+
19181919
how : {'E', 'S', 'end', 'start'}, default 'end'
1919-
Start or end of the timespan.
1920+
Specifies whether to align the converted period to the start or end of the interval:
1921+
- 'E' or 'end': Align to the end of the interval.
1922+
- 'S' or 'start': Align to the start of the interval.
19201923

19211924
Returns
19221925
-------
1923-
resampled : Period
1926+
Resampled Period : A new Period object with the specified frequency, aligned according to the `how` parameter.
1927+
1928+
See Also
1929+
--------
1930+
Period.end_time : Return the end Timestamp.
1931+
Period.start_time : Return the start Timestamp.
1932+
Period.dayofyear : Return the day of the year.
1933+
Period.dayofweek : Return the day of the week.
19241934

19251935
Examples
19261936
--------
1927-
>>> period = pd.Period('2023-1-1', freq='D')
1937+
Convert a daily period to an hourly period, aligning to the end of the day:
1938+
1939+
>>> period = pd.Period('2023-01-01', freq='D')
19281940
>>> period.asfreq('h')
19291941
Period('2023-01-01 23:00', 'h')
1942+
1943+
Convert a monthly period to a daily period, aligning to the start of the month:
1944+
1945+
>>> period = pd.Period('2023-01', freq='M')
1946+
>>> period.asfreq('D', how='start')
1947+
Period('2023-01-01', 'D')
1948+
1949+
Convert a yearly period to a monthly period, aligning to the last month of the year:
1950+
1951+
>>> period = pd.Period('2023', freq='Y')
1952+
>>> period.asfreq('M', how='end')
1953+
Period('2023-12', 'M')
1954+
1955+
Convert a monthly period to an hourly period, aligning to the start of the first day of the month:
1956+
1957+
>>> period = pd.Period('2023-01', freq='M')
1958+
>>> period.asfreq('h', how='start')
1959+
Period('2023-01-01 00:00', 'H')
1960+
1961+
Convert a weekly period to a daily period, aligning to the last day of the week:
1962+
1963+
>>> period = pd.Period('2023-08-01', freq='W')
1964+
>>> period.asfreq('D', how='end')
1965+
Period('2023-08-04', 'D')
1966+
19301967
"""
19311968
freq = self._maybe_convert_freq(freq)
19321969
how = validate_end_alias(how)

0 commit comments

Comments
 (0)