datamash -t, --header-in -g 3 trimmean:0.1 4 < data.csv

Category: Data Science & Analysis

datamash -t, --header-in -g 3 trimmean:0.1 4 < data.csv

Compute trimmed mean of column 4 grouped by column 3

Applies the 10 percent trimmed mean to column 4 separately for each group found in column 3. Per-group trimmed means are useful when some groups contain outlier values that would skew a plain average. The grouping flag -g works with every datamash operation, not just this one. Results are one row per group, in first-seen order unless -s is added.
Looking for more? Search all 7,657 commands — works offline, in English or Spanish, and fixes typos.