Skip to content

bottom

relationalai.semantics.std.aggregates
bottom(limit: int, *args: AggValue) -> Aggregate

Get the bottom N results in ascending order.

Parameters

  • limit

    (int) - Number of bottom results to return.
  • *args

    (AggValue, default: ()) - Values to order by (ascending).

Returns

  • Aggregate - An Aggregate representing the computation of the bottom N results.

Examples

Get 10 lowest-priced products:

select(Product).where(aggregates.bottom(10, Product.price))

Get 5 least selling products per category:

select(Product).where(
aggregates.bottom(5, Product.units_sold)
.per(Category)
.where(Product.category == Category)
)

Referenced By

RelationalAI Documentation
├──  Build With RelationalAI
│   └──  Understand how PyRel works
│       ├──  Build a semantic model
│       │   └──  Query a model
│       │       └──  Rank and select top results with rank, asc, desc, and top
│       └──  Use advanced reasoning > Rules-based reasoning
│           └──  Aggregate and group data
│               └──  Pick top and bottom results
└──  Release Notes
    └──  Python API Release Notes
        └──  What’s New in Version 1.17.0
            └──  Bug Fixes and Diagnostics