Finding the Weekday of a Date in Python – Complete Guide for Data Science 2026
Determining the weekday (Monday, Tuesday, etc.) of a date is one of the most common operations in data science. It is used for creating day-of-week features, analyzing weekly seasonality, building business calendars, and generating insightful reports. In 2026, Python offers several clean and efficient ways to get the weekday of any date.
TL;DR — Recommended Methods
date.weekday()→ 0 = Monday, 6 = Sundaydate.isoweekday()→ 1 = Monday, 7 = Sundaydate.strftime("%A")→ Full day name ("Monday")- pandas
.dt.day_name()and.dt.weekday→ vectorized for DataFrames
1. Pure Python – datetime.date
from datetime import date
d = date(2026, 3, 19)
print(d.weekday()) # 3 → Thursday (0=Monday)
print(d.isoweekday()) # 4 → Thursday (1=Monday)
print(d.strftime("%A")) # "Thursday"
print(d.strftime("%a")) # "Thu"
2. pandas – Vectorized Weekday Extraction
import pandas as pd
df = pd.read_csv("sales_data.csv", parse_dates=["order_date"])
# Add weekday features
df["weekday_number"] = df["order_date"].dt.weekday # 0 = Monday
df["day_name"] = df["order_date"].dt.day_name() # "Thursday"
df["day_name_short"] = df["order_date"].dt.day_name(locale="en_US.utf8").str[:3]
df["is_weekend"] = df["order_date"].dt.weekday.isin([5, 6])
print(df[["order_date", "day_name", "is_weekend"]].head())
3. Real-World Data Science Examples
# Example 1: Weekly seasonality analysis
weekly_sales = df.groupby(df["order_date"].dt.day_name())["amount"].mean()
# Example 2: Business-day vs weekend filtering
business_days = df[~df["order_date"].dt.weekday.isin([5, 6])]
weekend_sales = df[df["order_date"].dt.weekday.isin([5, 6])]
4. Best Practices in 2026
- Use pandas
.dt.day_name()and.dt.weekdayfor large DataFrames - Prefer
.weekday()(0=Monday) for most calculations - Use
strftime("%A")only when you need the full name as a string - Always work with timezone-aware datetimes before extracting weekday
- Create
is_weekendfeature early in your pipeline
Conclusion
Finding the weekday of a date is simple yet extremely valuable in data science. In 2026, combine Python’s date.weekday() / strftime() with pandas’ vectorized .dt accessor to create powerful day-of-week features, analyze weekly patterns, and build smarter time-based models.
Next steps:
- Add weekday and weekend features to one of your current datasets using the patterns above