Skip to content

Commit 9642eec

Browse files
natmokvalpmhatre1
authored andcommitted
DOC: add to to_offset the missing parameter is_period and examples (pandas-dev#56789)
add missing parameter is_period and examples to to_offsets
1 parent aeaf086 commit 9642eec

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed

pandas/_libs/tslibs/offsets.pyx

+15
Original file line numberDiff line numberDiff line change
@@ -4734,6 +4734,10 @@ cpdef to_offset(freq, bint is_period=False):
47344734
Parameters
47354735
----------
47364736
freq : str, datetime.timedelta, BaseOffset or None
4737+
The frequency represented.
4738+
is_period : bool, default False
4739+
Convert string denoting period frequency to corresponding offsets
4740+
frequency if is_period=True.
47374741
47384742
Returns
47394743
-------
@@ -4768,6 +4772,17 @@ cpdef to_offset(freq, bint is_period=False):
47684772
47694773
>>> to_offset(pd.offsets.Hour())
47704774
<Hour>
4775+
4776+
Passing the parameter ``is_period`` equal to True, you can use a string
4777+
denoting period frequency:
4778+
4779+
>>> freq = to_offset(freq="ME", is_period=False)
4780+
>>> freq.rule_code
4781+
'ME'
4782+
4783+
>>> freq = to_offset(freq="M", is_period=True)
4784+
>>> freq.rule_code
4785+
'ME'
47714786
"""
47724787
if freq is None:
47734788
return None

0 commit comments

Comments
 (0)