Skip to content

daft.count('all') for use in group-by without any column names #4033

@MarcoGorelli

Description

@MarcoGorelli

Is your feature request related to a problem?

Related to #3985, but I'm looking for a daft.len() expression to use in group-by

Describe the solution you'd like

import daft
df = daft.from_pydict({'a': [1,1,2], 'b': [4,5,6], 'c': [7,8,9]})
df.groupby('a').agg(daft.col('b').sum(), daft.count('all').alias('count'))

Describe alternatives you've considered

Some previous discussion at #3985 , but there I was pointed to Expression.count. That works, but outside the group-by context when a column names is passed, e.g.

In [40]: df.agg(daft.col('a').count('all')).collect()
Out[40]:
╭────────╮
│ a      │
│ ---    │
│ UInt64 │
╞════════╡
│ 3      │
╰────────╯

Additional Context

This is for Daft support in Narwhals

Would you like to implement a fix?

No

Metadata

Metadata

Assignees

Labels

enhancementNew feature or requestnarwhalsFeatures/Bugs related to supporting narwhalsp2 (backlog)Nice to have features

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions