Data Science

Working with Dates and Times in Pandas

Senior Data Analyst
April 22, 2026
6 min read

Convert to Datetime

df['order_date'] = pd.to_datetime(df['order_date'])

Extract Components

df['year'] = df['order_date'].dt.year

df['month'] = df['order_date'].dt.month

df['day_of_week'] = df['order_date'].dt.dayofweek

Time-Based Filtering

df[df['order_date'] > '2026-01-01']

*Day 113: Time Series Resampling.*

Ready to put your knowledge into practice?

Join SQL Mastery and learn through interactive exercises.