atoti.agg.min_member module#

atoti.agg.min_member(measure, /, level)#

Return a measure equal to the member minimizing the passed measure on the given level.

When multiple members minimize the passed measure, the first one (according to the order of the given level) is returned.

  • measure (NonConstantMeasureConvertible) – The measure to minimize.

  • level (Level) – The level on which the minimizing member is searched for.

Return type



>>> df = pd.DataFrame(
...     columns=["Continent", "City", "Price"],
...     data=[
...         ("Europe", "Paris", 200.0),
...         ("Europe", "Berlin", 150.0),
...         ("Europe", "London", 240.0),
...         ("North America", "New York", 270.0),
...     ],
... )
>>> table = session.read_pandas(
...     df,
...     table_name="City price table",
... )
>>> table.head()
       Continent      City  Price
0         Europe     Paris  200.0
1         Europe    Berlin  150.0
2         Europe    London  240.0
3  North America  New York  270.0
>>> cube = session.create_cube(table, mode="manual")
>>> h, l, m = cube.hierarchies, cube.levels, cube.measures
>>> h["Geography"] = [table["Continent"], table["City"]]
>>> m["Price"] = tt.agg.single_value(table["Price"])
>>> m["City with minimum price"] = tt.agg.min_member(m["Price"], l["City"])

At the given level, the measure is equal to the current member of the City level:

>>> cube.query(m["City with minimum price"], levels=[l["City"]])
                       City with minimum price
Continent     City
Europe        Berlin                    Berlin
              London                    London
              Paris                      Paris
North America New York                New York

At a level above it, the measure is equal to the city of each continent with the minimum price:

>>> cube.query(m["City with minimum price"], levels=[l["Continent"]])
              City with minimum price
Europe                         Berlin
North America                New York

At the top level, the measure is equal to the city with the minimum price across all continents:

>>> cube.query(m["City with minimum price"])
  City with minimum price
0                  Berlin