Finding the Dates a Number of Days Before & After

Python

In this code snippet, we create two dataframe columns containing the dates 7 days after and 7 days before the date in the "order_date" column.

 1|  orders['week_after_order'] = orders['Order_Date'] + dt.timedelta(days=7)
 2|  orders['week_before_order'] = orders['Order_Date'] - dt.timedelta(days=7)
Did you find this snippet useful?

Sign up for free to to add this to your code library