You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
We currently have Expr.mode and Series.mode, like Polars does. What's not great about them is that they don't aggregate
I'd like to suggest a departure from Polars here. We introduce Expr.mode_any and Series.mode_any, which actually aggregate, but make no guarantees about which mode will be returned. For example, if a column contains values [1, 2, 2, 3, 3, 4], then it may return 2 or it may return 3.
The text was updated successfully, but these errors were encountered:
Alternatively, per #1657, if we disallow length-changing-non-aggregating expressions which aren't followed by aggregations, then we might be able to get away with just Expr.mode, and just require that it be followed by an aggregation, .e. nw.col('a').mode().first(order_by='id'). We could even introduce Expr.any_value and allow nw.col('a').mode().any_value()
Returning a list would definitly be consistent with polars mode behavior in a group by context. We might always return a list type (and enhance a bit the list namespace with .first, .last, .__getitem__)
I'm not sold on returning lists here for expressions which don't aggregate, and I think Polars is a bit internally inconsistent here. .list is also a bit problematic for some backends, like pandas non-pyarrow-backed, whereas with nw.col('a').mode().any_value() / nw.col('a').mode().first(order_by='id') we can bypass the list and have a return value which works well for all implementations
We currently have
Expr.mode
andSeries.mode
, like Polars does. What's not great about them is that they don't aggregateI'd like to suggest a departure from Polars here. We introduce
Expr.mode_any
andSeries.mode_any
, which actually aggregate, but make no guarantees about which mode will be returned. For example, if a column contains values[1, 2, 2, 3, 3, 4]
, then it may return2
or it may return3
.The text was updated successfully, but these errors were encountered: