Notice: This page requires JavaScript to function properly.
Please enable JavaScript in your browser settings or update your browser.
Leer Date and Time-Based Features | Section
Engineering Temporal Features

bookDate and Time-Based Features

Veeg om het menu te tonen

Extracting calendar-based features from date and time information is a powerful technique in temporal feature engineering. By breaking down a timestamp into components such as the day of the week, month, or whether it falls on a weekend, you can capture recurring patterns or seasonality that often drive changes in real-world data. These features are especially valuable in time series forecasting, where many phenomena – like sales, traffic, or energy usage – follow predictable cycles tied to the calendar. For example, demand might spike on weekends or drop during certain months, and models that incorporate this information can make more accurate predictions.

12345678910111213141516
import pandas as pd # Create a sample datetime index dates = pd.date_range(start="2024-06-01", end="2024-06-14", freq="D") df = pd.DataFrame(index=dates) # Extract day of week (Monday=0, Sunday=6) df["day_of_week"] = df.index.dayofweek # Extract month df["month"] = df.index.month # Determine if the date is a weekend (Saturday=5, Sunday=6) df["is_weekend"] = df.index.dayofweek >= 5 print(df)
copy
question mark

Why are calendar-based features, such as day of week or month, important when building time series forecasting models?

Select the correct answer

Was alles duidelijk?

Hoe kunnen we het verbeteren?

Bedankt voor je feedback!

Sectie 1. Hoofdstuk 6

Vraag AI

expand

Vraag AI

ChatGPT

Vraag wat u wilt of probeer een van de voorgestelde vragen om onze chat te starten.

Sectie 1. Hoofdstuk 6
some-alt