pandas.tseries.frequencies.to_offset

pandas.tseries.frequencies.to_offset(freq)[source]

Return DateOffset object from string or tuple representation or datetime.timedelta object

Parameters:
freq : str, tuple, datetime.timedelta, DateOffset or None
Returns:

delta : DateOffset

None if freq is None

Raises:

ValueError

If freq is an invalid frequency

See also

pandas.DateOffset

Examples

>>> to_offset('5min')
<5 * Minutes>
>>> to_offset('1D1H')
<25 * Hours>
>>> to_offset(('W', 2))
<2 * Weeks: weekday=6>
>>> to_offset((2, 'B'))
<2 * BusinessDays>
>>> to_offset(datetime.timedelta(days=1))
<Day>
>>> to_offset(Hour())
<Hour>
Scroll To Top