Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[stdlib-candidate] add aggregate #991

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

Bahex
Copy link

@Bahex Bahex commented Dec 10, 2024

Description

Add aggregate, a command that operates on the output of group-by --to-table to help aggregate to do quick inspections.

Related

Examples

open ~/Downloads/movies.csv
  | group-by Lead_Studio Genre --to-table
  | aggregate Worldwide_Gross
  # | first 4
  # | to md
Lead_Studio Genre count Worldwide_Gross_min Worldwide_Gross_avg Worldwide_Gross_max Worldwide_Gross_sum
The Weinstein Company Comedy 1 19.62 19.62 19.62 19.62
The Weinstein Company Drama 1 8.26 8.26 8.26 8.26
Independent Comedy 7 14.31 57.01 205.3 399.07
Independent Romance 7 0.03 149.82142857142858 702.17 1048.75

open ~/Downloads/movies.csv
  | group-by Lead_Studio Genre --to-table
  | aggregate Worldwide_Gross --ops {avg: {math avg}, std: {math stddev}}
  # | first 4
  # | to md
Lead_Studio Genre count Worldwide_Gross_avg Worldwide_Gross_std
The Weinstein Company Comedy 1 19.62 0
The Weinstein Company Drama 1 8.26 0
Independent Comedy 7 57.01 66.1709932134704
Independent Romance 7 149.82142857142858 229.79475832816996

open ~/Downloads/movies.csv
  | group-by Lead_Studio Genre --to-table
  | aggregate Worldwide_Gross Audience_score_% --ops {avg: {math avg}}
  # | first 4
  # | to md
Lead_Studio Genre count Worldwide_Gross_avg Audience_score_%_avg
The Weinstein Company Comedy 1 19.62 52
The Weinstein Company Drama 1 8.26 84
Independent Comedy 7 57.01 60.142857142857146
Independent Romance 7 149.82142857142858 59.857142857142854

@fdncred
Copy link
Collaborator

fdncred commented Dec 10, 2024

My initial thought is to just land this PR because I want to use it. But we need to follow the readme so we need tests. The documentation is probably ok but I'd like to see more examples with different agg ops.

I love this script, and I already have a version of it from discord in my own custom commands that I source at every startup. Good work and thanks for adding this here.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants