import pandas as pd
dim_tiempo = pd.DataFrame({
"time_key": [1, 2], "quarter": ["Q1", "Q2"], "year": [2025, 2025],
})
dim_ubicacion = pd.DataFrame({
"location_key": [1, 2, 3, 4],
"city": ["CDMX", "Guadalajara", "Monterrey", "Merida"],
"region": ["Central", "West", "North", "Southeast"],
})
dim_departamento = pd.DataFrame({
"dept_key": [1, 2, 3, 4],
"department": ["Wood", "Plumbing", "Decoration", "Electrical"],
})
fact_ventas = pd.DataFrame([
(1, 1, 1, 70), (1, 1, 2, 40), (1, 1, 3, 20), (1, 1, 4, 30),
(2, 1, 1, 50), (2, 1, 2, 60), (2, 1, 3, 22), (2, 1, 4, 28),
(1, 2, 1, 60), (1, 2, 2, 35), (1, 2, 3, 25), (1, 2, 4, 40),
(2, 2, 1, 45), (2, 2, 2, 50), (2, 2, 3, 30), (2, 2, 4, 35),
(1, 3, 1, 48), (1, 3, 2, 38), (1, 3, 3, 18), (1, 3, 4, 26),
(2, 3, 1, 36), (2, 3, 2, 55), (2, 3, 3, 25), (2, 3, 4, 30),
(1, 4, 1, 52), (1, 4, 2, 42), (1, 4, 3, 15), (1, 4, 4, 37),
(2, 4, 1, 44), (2, 4, 2, 33), (2, 4, 3, 20), (2, 4, 4, 28),
], columns=["time_key", "location_key", "dept_key", "sales_amount"])
data_mart = (
fact_ventas
.merge(dim_tiempo, on="time_key")
.merge(dim_ubicacion, on="location_key")
.merge(dim_departamento, on="dept_key")
)
data_mart.head()