Transform one time purchases to cumulative sum for each month

My dataset looks like this. It contains purchase records within zipcodes, on a certain data. I would like to create a new dataframe and sum the number of purchases for each month in each zipcode. The problem is that sometimes there are months with no activity.

ID     Zipcode     Date          Purchase      
1        9999     2018-12-24        1
2        9999     2018-12-26        1
3        9999     2019-3-14         1
4        9999     2019-4-8          1
5        2400     2018-12-12        1
6        2400     2018-12-14        1
7        2400     2019-1-15         1
8        2400     2019-2-30         1

Ideally, the dataframe would look like this:

Zipcode    Period          Cumulative purchases
9999      December 2018            2
9999      January 2019             2
9999      February 2019            2
9999      March 2019               2
9999      April 2019               3
9999      May 2019                 3
2400      December 2018            2
2400      January 2019             3
2400      February 2019            4
2400      March 2019               4
2400      April 2019               4
etc

Answer

You can aggregate per ZipCode with resample by months by sum and then aggregate by first level, here Zipcode by cumulative sum:

df['Date'] = pd.to_datetime(df['Date'])

df = (df.set_index('Date')
        .groupby('Zipcode', sort=False)
        .resample('MS')['Purchase'].sum()
        .groupby(level=0)
        .cumsum()
        .reset_index(name='Cumulative purchases'))

df['Date'] = df['Date'].dt.strftime('%B %Y')
print (df)
   Zipcode           Date  Cumulative purchases
0     9999  December 2018                     2
1     9999   January 2019                     2
2     9999  February 2019                     2
3     9999     March 2019                     3
4     9999     April 2019                     4
5     2400  December 2018                     2
6     2400   January 2019                     3
7     2400  February 2019                     4