Premium problem34. Mean per Calendar Month

Medium Locked

Given a date-indexed Series s, return the mean of the values grouped by calendar month. Index the result by the last calendar day of each month.

Input

2015-01-01      0
2015-01-02      1
2015-01-05      2
2015-01-06      3
2015-01-07      4
             ... 
2015-12-25    256
2015-12-28    257
2015-12-29    258
2015-12-30    259
2015-12-31    260
Freq: B, Length: 261, dtype: int64

Output

2015-01-31     10.5
2015-02-28     31.5
2015-03-31     52.5
2015-04-30     74.5
2015-05-31     96.0
2015-06-30    117.5
2015-07-31    140.0
2015-08-31    162.0
2015-09-30    183.5
2015-10-31    205.5
2015-11-30    227.0
2015-12-31    249.0
Freq: ME, dtype: float64

Premium problem

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

Implement solve(...)