Implement a tiny GROUP BY: given rows (dictionaries), a key column and a value column, return one row
per key with count, sum and avg (rounded to two decimals) of the value column. Rows whose value is
None are counted in count but excluded from sum and avg (like SQL). avg is None when no value
is present. Return the groups sorted by key.
Implement group_by. Input: rows: list[dict], key: str, value: str. Returns: list[dict] with key, count, sum, avg.
def group_by(rows: list[dict], key: str, value: str) -> list[dict]:
return []
Run executes the public tests. Submit grades against public and hidden tests.
Implement a tiny GROUP BY: given rows (dictionaries), a key column and a value column, return one row
per key with count, sum and avg (rounded to two decimals) of the value column. Rows whose value is
None are counted in count but excluded from sum and avg (like SQL). avg is None when no value
is present. Return the groups sorted by key.
Implement group_by. Input: rows: list[dict], key: str, value: str. Returns: list[dict] with key, count, sum, avg.
def group_by(rows: list[dict], key: str, value: str) -> list[dict]:
return []
Run executes the public tests. Submit grades against public and hidden tests.