Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions pandas/_libs/tslibs/offsets.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -4734,6 +4734,10 @@ cpdef to_offset(freq, bint is_period=False):
Parameters
----------
freq : str, datetime.timedelta, BaseOffset or None
The frequency represented.
is_period : bool, default False
Convert string denoting period frequency to corresponding offsets
frequency if is_period=True.

Returns
-------
Expand Down Expand Up @@ -4768,6 +4772,17 @@ cpdef to_offset(freq, bint is_period=False):

>>> to_offset(pd.offsets.Hour())
<Hour>

Passing the parameter ``is_period`` equal to True, you can use a string
denoting period frequency:

>>> freq = to_offset(freq="ME", is_period=False)
>>> freq.rule_code
'ME'

>>> freq = to_offset(freq="M", is_period=True)
>>> freq.rule_code
'ME'
"""
if freq is None:
return None
Expand Down