Premium problem145. Average Order Value per Customer

Medium Locked

Given ids (1-D int in [0, k)) and amounts (1-D float, same length), return a float array of length k giving each id's mean amount, with np.nan for ids having no rows.

Input

ids = [0 0 2]
amounts = [10. 20.  5.]
k = 4

Output

[15. nan  5. nan]

Premium problem

This one's part of Premium. Unlock the full NumPy track plus every other premium problem on the site.

Implement solve(...)