(
table: pw.Table, *on: pw.ColumnReference, what: pw.ColumnExpression
)
| 6 | |
| 7 | |
| 8 | def argmax_rows( |
| 9 | table: pw.Table, *on: pw.ColumnReference, what: pw.ColumnExpression |
| 10 | ) -> pw.Table: |
| 11 | filter = ( |
| 12 | table.groupby(*on) |
| 13 | .reduce(argmax_id=pw.reducers.argmax(what)) |
| 14 | .with_id(pw.this.argmax_id) |
| 15 | .promise_universe_is_subset_of(table) |
| 16 | ) |
| 17 | return table.restrict(filter) |
| 18 | |
| 19 | |
| 20 | def argmin_rows( |