I am trying to build a function in Python where if a user provides an offset frequency such as 1D
10M
1Y
then I can provide the date using the offset.
Example if user inputs 1M
along with a date 2021-08-25
pd.Timestamp('2021-08-25') - pd.tseries.frequencies.to_offset('1M')
The above code outputs Timestamp('2021-07-31 00:00:00')
which is not one month prior to the date provided by user. Expected Output Timestamp('2021-07-25 00:00:00')
How can I achieve this?