[QST] Is there a way to do custom aggregations?
See original GitHub issueFor example I want to get the total progress within a group. My code looks like:
cols = ["user", "timecode", "published_at"]
aggs = {
'timecode': ["first", "last"],
}
usages = cols >> nvt.ops.Groupby(
groupby_cols="user"
sort_cols=["published_at"],
aggs=aggs,
name_sep="_")
dataset = nvt.Dataset(data)
workflow = nvt.Workflow(all_feats)
sessions_gdf = workflow.fit_transform(dataset).to_ddf()
sessions_gdf["progress"] = sessions_gdf.progress_last - sessions_gdf.progress_first
Is there a way to include the subtraction into the workflow? I tested a couple of things like:
aggs = {
'progress': [nvt.ops.LambdaOp(lambda col: col.last() - col.first())],
}
or
aggs = {
'progress': [lambda col: col.last() - col.first()]
}
but neither seems to be supported. Is there another way to express this?
Issue Analytics
- State:
- Created 2 years ago
- Comments:6 (3 by maintainers)
Top Results From Across the Web
[QST] Is there a way to do custom aggregations? #1164 - GitHub
For example I want to get the total progress within a group. My code looks like: cols = ["user", "timecode", "published_at"] aggs ...
Read more >Creating Custom Aggregations to Use with Pandas groupby
A simple way to apply these aggregations is to create a list and pass that list as an argument. This method will apply...
Read more >Implementing Custom Aggregations | TensorFlow Federated
In this tutorial, we explain design principles behind the tff.aggregators module and best practices for implementing custom aggregation of values from ...
Read more >Aggregate functions - Amazon QuickSight - AWS Documentation
Custom aggregations can 't contain both aggregated and nonaggregated fields, in any combination. For example, this formula doesn't work: Sum(sales)+quantity .
Read more >Write custom aggregation function in Pandas - GeeksforGeeks
Now, let's perform some operations: 1. Performing aggregation over the rows: This performs aggregate functions over the rows of the Dataframe.
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Thanks, that looks great, will try that!
@krlng is the workaround above works for you? can we close this issue? thanks.