1 Upvote

Finding the Dates a Number of Days Before & After

Python
Data Preprocessing

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.

orders['week_after_order'] = orders['Order_Date'] + dt.timedelta(days=7)
orders['week_before_order'] = orders['Order_Date'] - dt.timedelta(days=7)

By analyseup - Last Updated Jan. 13, 2022, 12:15 a.m.

Did you find this snippet useful?

Sign up to bookmark this in your snippet library

COMMENTS
RELATED SNIPPETS
Pivoting Pandas Dataframes
Python
Data Preprocessing

Pandas

3
SparkSession instantiate
Python
Data Preprocessing

2
Converting Data Types
Python
Data Preprocessing

Data-cleaning

2
Data Minification
Python
Data Preprocessing

Cleaning

2
Top Contributors
75