Compute the mean of values for each distinct key in keys (a group-by-mean) without using pandas. keys[i] is the group of values[i].
Implement solve(keys, values).
Returns. Return a dict mapping each key to the mean of its values. Keys appear in order of first occurrence.
Example 1
Input:
solve(['a', 'a', 'b'], [1.0, 2.0, 4.0])
Output:
{'a': 1.5, 'b': 4.0}
Example 2
Input:
solve(['x', 'y', 'x', 'y', 'x'], [10.0, 1.0, 20.0, 3.0, 30.0])
Output:
{'x': 20.0, 'y': 2.0}
No results yet
Run your code to check it against the examples, or submit to run every test.