If I have a variable (in pd.datetime
format):
date_value = pd.to_datetime("2019-12-10 10:57:00")
... how can I subtract a pandas frequency value from that datetime? For example, I may want to subtract "1min"
, or "15min"
, or "1B"
, or "1W"
from that value.
These frequency values are stored as strings, and instead of parsing each string value for the integer and time value (min, day, week, etc.) which would be annoying, I'm wondering if there's a way to utilize the freq string values directly. Pseudo-code would look something like this:
new_date_value = date_value - timedelta("1min")
...but of course timedelta
doesn't use the freq strings. Is there another way to do this?