Skip to content

avg

relationalai.semantics.std.aggregates
avg(*args: AggValue) -> Aggregate

Compute the average of values.

  • *args

    (AggValue, default: ()) - Values to average.
  • Aggregate - An Aggregate representing the computation of the average. Returns ScaledNumber if the input is Number, or Float if the input is Float.

Compute average salary:

>>> select(aggregates.avg(Employee.salary))

Compute average order amount per customer:

>>> select(Customer, aggregates.avg(Order.amount).per(Customer).where(Order.customer == Customer))
RelationalAI Documentation
└──  Build With RelationalAI
    └──  Understand how PyRel works > Use advanced reasoning > Rules-based reasoning
        └──  Aggregate and group data
            └──  Average values with .avg()