This is the shape of nearly every fraud and churn feature in production, and it is where time-based features are most often written wrongly.
Given a DataFrame of transactions with columns customer_id, timestamp and amount, return a DataFrame with one row per input transaction and the columns:
customer_idtimestampamountrolling_7d_avg: the mean transaction amount for that customer over the 7 days ending at that transaction, inclusiveThe window is defined in time, not in number of rows: a customer with three transactions in one day and none for a month has a very different window from one who transacts daily.
Sort the output by customer_id then timestamp.
The trap: a transaction's own window must not include anything that happened after it. A feature that peeks into the future looks excellent offline and collapses in production.
Build the architecture on a canvas: place the components, configure them, connect them into a data flow, and write a short reason for each one. The AI reviewer grades your design against a rubric written specifically for this problem.
Minimum 5 components · needs a wide desktop screen