I have a Python time series modeling program where the user sets conditions, or variables, they want to use. One of the variables they set is 'cadence', which takes the values of 'days', 'weeks', 'months', etc. I want to then use this variable in Pandas' DateOffset
function to offset dates accordingly. How can I do this?
Below is an example of what I want, though this example does not work. In the example new_d
would take the value of '2019-01-15'.
import pandas as pd
cadence = 'weeks'
d = pd.Timestamp('2019-01-01')
new_d = d + pd.DateOffset(cadence=2)