Reputation: 11
You can do pd.to_timedelta('30min')
to get a timedelta object of 30 minutes. Is there a similar way to go from a timedelta object to the freq string (like '30min', '1H', etc.)?
Upvotes: 1
Views: 1412
Reputation: 31
you can create a pd.DateOffset and use its freqstr attribute:
import pandas as pd
from pandas.tseries.frequencies import to_offset
offset = to_offset(pd.Timedelta('30min'))
print(offset.freqstr)
# 30T
Upvotes: 3