Given a dataset of user transactions, write a Pandas script to calculate the rolling 7-day average of purchase amounts.
For this SQL version, use the transactions table and calculate the average for each transaction over the inclusive seven-day calendar window ending on its transaction date. NULL purchase amounts should not contribute to the average.
user_id, transaction_date, transaction_id, and rolling_7_day_avguser_id, transaction_date, and transaction_id ascending| Column | Type | Description |
|---|---|---|
| transaction_idPK | INT | Unique transaction identifier |
| user_id | VARCHAR(20) | Identifier of the user who made the purchase |
| transaction_date | DATE | Calendar date of the transaction |
| purchase_amount | DECIMAL(10,2) | Purchase amount, which may be NULL when unavailable |