enso
enso copied to clipboard
Add `Table.running` function to compute grouped running statistics.
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
Would like to agree the design on this and then we can move forward.
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
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.
Weighted Average pulled to a separate ticket
Add the following function to Statistic:
Product
Should be a separate ticket