Lag Feature Matrix

~10 mincode completion

Implement lag_features(series, k) returning the array whose row for time is . Assume .

Where this shows up

~10 min

8 employers weight this skill

3 big tech firms, 2 AI product companies, 1 defense company, 1 enterprise vendor, 1 quant fund. Top match scores 87.

Python
import numpy as np


def lag_features(series, k):
    """
    Build a lag feature matrix from a 1D series.

    Args:
        series: array of shape (n,), in time order
        k:      number of lags, 1 <= k < n

    Returns:
        array of shape (n - k, k); row i is [y[t-1], ..., y[t-k]] for t = k + i
    """
    # YOUR CODE HERE
    pass

Run your code to see results

⌘↵ runs against the visible tests

Loading docs…

The AI Mentor needs an account

It reads your code and the failing tests and nudges you toward the fix without handing you the answer. Free accounts get it on every problem you're working on today.