mirror of
https://github.com/lynchmarkHQ/lynchmark.com.git
synced 2026-10-19 02:07:52 +00:00
Docs: Update Gemini benchmark results
This commit is contained in:
@@ -0,0 +1,18 @@
|
||||
const processCSV = async (csvString, { filterColumn, filterValue, groupBy, aggregateColumn, operation }) => {
|
||||
const [{ csvParse }, { rollup, sum, mean }] = await Promise.all([
|
||||
import('https://cdn.jsdelivr.net/npm/d3-dsv@3/+esm'),
|
||||
import('https://cdn.jsdelivr.net/npm/d3-array@3/+esm')
|
||||
]);
|
||||
|
||||
const getValue = d => +d[aggregateColumn] || 0;
|
||||
const data = csvParse(csvString).filter(d => d[filterColumn] == filterValue);
|
||||
|
||||
const aggregated = rollup(
|
||||
data,
|
||||
g => operation === 'count' ? g.length : (operation === 'sum' ? sum : mean)(g, getValue),
|
||||
d => d[groupBy]
|
||||
);
|
||||
|
||||
return Array.from(aggregated, ([key, result]) => ({ [groupBy]: key, result }));
|
||||
};
|
||||
export default processCSV;
|
||||
Reference in New Issue
Block a user