ankane/ruby-polars

Feature Request: support `df.group_by(...).agg(new_col: ...)` like `df.with_columns(new_col: ...)`

DeflateAwning opened this issue · 2 comments

It would be awesome if .agg() supported the same semantics as .with_columns(...) and .select(...). That is, I wish .agg had support for naming new columns as kwargs to the method call.

Example which works with .with_columns, but not with .agg:

# works
df.with_columns(
                volume_cumulative: Polars.col('volume').cum_sum,
)

# doesn't work
df.group_by('date').agg(
                volume_cumulative: Polars.col('volume').sum,
)

Hi @DeflateAwning, added in the commit above.

Amazing, thanks!