>>> df = pd.DataFrame(
... columns=["Year", "Month", "Day", "Quantity"],
... data=[
... (2019, 7, 1, 15),
... (2019, 7, 2, 20),
... (2019, 7, 3, 30),
... (2019, 6, 1, 25),
... (2019, 6, 2, 15),
... (2018, 7, 1, 5),
... (2018, 7, 2, 10),
... (2018, 6, 1, 15),
... (2018, 6, 2, 5),
... ],
... )
>>> table = session.read_pandas(
... df,
... default_values={"Year": 0, "Month": 0, "Day": 0},
... table_name="Origin",
... )
>>> cube = session.create_cube(table, mode="manual")
>>> h, l, m = cube.hierarchies, cube.levels, cube.measures
>>> h["Date"] = [table["Year"], table["Month"], table["Day"]]
>>> m["Quantity.SUM"] = tt.agg.sum(table["Quantity"])
>>> m["Average of monthly quantities"] = tt.agg.mean(
... m["Quantity.SUM"], scope=tt.OriginScope({l["Month"]})
... )