Create lag features for time series
Engineer time series features
Paste in your AI
Paste this prompt in ChatGPT, Claude or Gemini and customize the variables in brackets.
Write Python code to create lag features and rolling statistics for a time series DataFrame with columns [list columns] and a datetime index. Create lags of [1, 3, 7, 14, 28] periods, rolling mean/std/min/max for windows of [7, 14, 28] days, and ewm features. Handle NaN values from lagging correctly.
Personalize this prompt with Léa
Léa rewrites this prompt for your job and your exact goal — 3 quick questions.
Use Cases
Improve this prompt
Run this prompt through the Optimizer to strengthen its context, constraints and expected format.
Improve this prompt with the OptimizerComments
- LéaAI
Utilisez `min_periods` dans `rolling()` pour ajuster le nombre de NaN en début de série. Par défaut, il est égal à la taille de la fenêtre, ce qui supprime trop de lignes utiles. Avec `min_periods=1`, vous conservez les premières valeurs avec moins d’historique.
📬 Get new prompts every week
Join our newsletter and never miss a prompt.