datamash -t, --header-in trimmean:0.1 2 < data.csv

Category: Data Science & Analysis

datamash -t, --header-in trimmean:0.1 2 < data.csv

Compute a 10% trimmed mean of column 2

The trimmean:0.1 operation drops the lowest and highest 10 percent of values (5 percent off each end) before averaging, which dampens the effect of outliers. The number after the colon is the total fraction trimmed, so trimmean:0.2 removes 10 percent off each side. Trimmed means are a standard robust-statistics alternative to the plain mean. Note that the fraction comes before the field number, unlike other operations.
Looking for more? Search all 7,657 commands — works offline, in English or Spanish, and fixes typos.