Transform raw data into weekly sales forecasting population table.
API:
from data import create_weekly_sales_by_store_with_target
result = create_weekly_sales_by_store_with_target(
session,
source_schema="RAW",
target_schema="PREPARED"
)
Output: population_weekly_by_store_with_target
| Column |
Type |
Description |
store_id |
VARCHAR |
Store identifier (join key) |
reference_date |
DATE |
Monday of week (time stamp) |
total_sales |
FLOAT |
Weekly sales total |
total_orders |
INT |
Weekly order count |
target |
FLOAT |
Next week's total_sales |
Files:
data/preparation.py
data/sql/preparation/*.sql
Key Logic:
reference_date = DATE_TRUNC('week', order_date) (Monday)
target = LEAD(total_sales) OVER (PARTITION BY store_id ORDER BY reference_date)
- Final week excluded (no target)
Transform raw data into weekly sales forecasting population table.
API:
Output:
population_weekly_by_store_with_targetstore_idreference_datetotal_salestotal_orderstargetFiles:
data/preparation.pydata/sql/preparation/*.sqlKey Logic:
reference_date=DATE_TRUNC('week', order_date)(Monday)target=LEAD(total_sales) OVER (PARTITION BY store_id ORDER BY reference_date)