New feature: Lag or windows features grouped by

Open
#668 2 comments 2 reactions 0 assignees View on GitHub

Maintainers usually reply within 1 day

Nobody has claimed this yet.

  • #1109 by @lcrmorin — closed without merging

Assessment

Difficulty
4/5
Estimated time
3-5 days
Newbie friendliness
18/100
Issue type
Feature
Clarity
Mostly clear
Activity status
Stale
Tech stack
pandas, python

Research direction

The issue asks for lag and window features to be computed per group, using the pandas groupby-then-lag pattern as the reference. Work is already under way in linked pull request #1109, so read that PR first to see what it covers before starting. The issue text names no files, so locate the existing lag-feature transformer in the repository. Done means grouping by one or more columns works and the tests pass.

Written by the indexing model from the issue text.

Description

Is your feature request related to a problem? Please describe.
For example, you want to create lag features of sales for a retail chain, but taking into account the stores, product categories, and date. It's widespread to create lag features taking into consideration the hierarchy or grouping levels.

Describe the solution you'd like
I would like the la feature creation but apply groups by different columns in the data frame.

Describe alternatives you've considered
An alternative solution would be to create a sklearn transformer class to apply the groupby and lag functions of pandas.

Here is an example of what I'm talking about using pandas: https://www.statology.org/pandas-lag-by-group/

Dominant language
Python
Stars
2.3k
Forks
391
Avg merge
11h 34m
Merged PRs (30d)
11

Getting set up

This project ships no dev container, Dockerfile or contributing guide, so setting up is up to you: start from its README, and see our first-contribution guide for the general steps.

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from feature-engine/feature_engine

All issues in feature-engine/feature_engine

Similar issues

More Python issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.