I am trying to convert YTD pandas dataframe into monthly data. Unfortunately the data is also missing values. The original data looks like table A

The preferred outcome should look like Table B

So the goal is to calculate the difference between each rows for each year, where the values are not zero. The second step should be to fill in the zeroes witch the average of the YTD data of the month which has values. I've tried a lot of things but never reached the preferred outcome. Support is much appreciated.