import pandas as pd
dim_tiempo = pd.DataFrame({
"id_tiempo": [1, 2], "trimestre": ["T1", "T2"], "anio": [2025, 2025],
})
dim_ubicacion = pd.DataFrame({
"id_ubicacion": [1, 2, 3, 4],
"ciudad": ["CDMX", "Guadalajara", "Monterrey", "Mérida"],
"region": ["Centro", "Occidente", "Norte", "Sureste"],
})
dim_departamento = pd.DataFrame({
"id_departamento": [1, 2, 3, 4],
"departamento": ["Madera", "Plomería", "Decoración", "Eléctrico"],
})
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=["id_tiempo", "id_ubicacion", "id_departamento", "monto_venta"])
data_mart = (
fact_ventas
.merge(dim_tiempo, on="id_tiempo")
.merge(dim_ubicacion, on="id_ubicacion")
.merge(dim_departamento, on="id_departamento")
)
data_mart.head()