>>> from datetime import date
>>> df = pd.DataFrame(
... columns=["Date", "Quantity"],
... data=[
... (date(2020, 1, 10), 150.0),
... (date(2020, 1, 20), 240.0),
... (date(2019, 3, 17), 270.0),
... (date(2019, 12, 12), 200.0),
... ],
... )
>>> table = session.read_pandas(df, keys={"Date"}, table_name="Example")
>>> cube = session.create_cube(table)
>>> l, m = cube.levels, cube.measures
>>> cube.create_date_hierarchy("Date parts", column=table["Date"])
>>> cube.query(
... m["Quantity.SUM"],
... include_totals=True,
... levels=[l["Year"], l["Month"], l["Day"]],
... )
Quantity.SUM
Year Month Day
Total 860.00
2019 470.00
3 270.00
17 270.00
12 200.00
12 200.00
2020 390.00
1 390.00
10 150.00
20 240.00