title: Python Pandas stack by zip code and group by month/year
body: <p>I have a large data frame with transaction data. What I am trying to do is use python to aggregate the data starting with zip codes, then a year and month, finally the total number of transactions for that month.</p>
  
  <p>My Df:</p>
  
  <pre><code>  Date        VAR1   VAR2    ZipCode    Transactions
  YYYY-MM-DD.    X.     Y.     12345.         1.      
  </code></pre>
  
  <p>So the first thing I did was convert the to date time</p>
  
  <pre><code> df['Date'] = pd.to_datetime(df['Date'])
   df.info()
   # Date datetime64[ns]
  </code></pre>
  
  <p>Then I split the data into year-month and number of transactions: </p>
  
  <pre><code># grouping the data by year and month
  per = df.Date.dt.to_period("M")  
  g = df.groupby(per)
  g.sum() # so now that this works, we need to break it up into zip codes
  </code></pre>
  
  <p>Which gives an output of: </p>
  
  <pre><code>Date.       Transactions
  YYYY-MM.        X
  YYYY-MM.        Y
  </code></pre>
  
  <p>My questions is, what am I missing to get the zipcodes in front:</p>
  
  <pre><code>ZipCode.     Date.    Transactions
   123345.   YYYY-MM.     sum()
  </code></pre>
  
  <p>Any and all help is greatly apprecaited</p>