enso icon indicating copy to clipboard operation
enso copied to clipboard

Add `Table.running` function to compute grouped running statistics.

Open jdunkerley opened this issue 1 year ago • 3 comments

Currently, we have Column.running statistic:Statistic name:Text -> Column = ... allowing for computing a single running statistic such as maximum and minimum.

This ticket is to add a table version of the function.

  • Should be able to compute the same set of statistics as on a Column.
  • Has to be able to compute within groups and with specified ordering
  • Like add_row_number it should add a column and return the table with the rows in the original order.
  • Not supported within database backend at least for now.
    • At least in theory, support for this exists in Postgres, MySQL, and SQL Server via Window functions (Partition by and Order by should handle grouping and sequence, and most functions should be supported). This may not work for ALL statistics, but should cover Sum, Product, etc. Will not cover Kurtosis and Skew.
  • Add the following functions to Statistic:
    • Weighted Average
    • Product

Suggested API:

Table.running input:Text|Integer statistic:Statistic name:Text group_by:Vector order_by:Vector
Table.running input statistic name group_by=Nothing order_by=Nothing

jdunkerley avatar Oct 31 '23 15:10 jdunkerley

Would like to agree the design on this and then we can move forward.

jdunkerley avatar Dec 12 '23 10:12 jdunkerley

In theory, we could possibly add full function support here, but I think it opens a can of worms without very careful UX. Would like to discuss and consider if its worthwhile as a follow-on effort

Cassandra-Clark avatar Feb 08 '24 21:02 Cassandra-Clark

In theory, we could possibly add full function support here, but I think it opens a can of worms without very careful UX. Would like to discuss and consider if its worthwhile as a follow-on effort

After discussion, this is best left to an offset/multi-row function instead of complicating the running command.

Cassandra-Clark avatar Feb 19 '24 21:02 Cassandra-Clark

Weighted Average pulled to a separate ticket

Cassandra-Clark avatar Mar 08 '24 16:03 Cassandra-Clark

Add the following function to Statistic:

Product

Should be a separate ticket

Cassandra-Clark avatar Mar 08 '24 16:03 Cassandra-Clark