title: Pandas divide creates extra columns and NaN
body: <p>I am trying to calculate a cumulative sum and then divide each column of this cumulative sum by another data frame column. See code below.</p>
  
  <pre><code>import pandas as pd
  import numpy as np
  
  
  def cum_sums(input_df):
  
      bin_values = np.arange(0, 72, 24)
      group_names = np.arange(0, 48, 24)
  
      input_df['categories'] = pd.cut(input_df['time'], bin_values, labels=group_names)
      category_sum = input_df.groupby(['area', 'categories'])['categories'].size()
      cum_sum = category_sum.groupby(level=[0]).cumsum().reset_index(name='cum_sum')
      # pivot to get right format
      cum_sum_flipped = cum_sum.pivot(index='area', columns='categories', values='cum_sum')
      # and then add back in any missing categories
      cum_sum_flipped = cum_sum_flipped.reindex(columns=group_names).ffill(axis=1).replace('Nan', 0, regex=True)
  
      return cum_sum_flipped
  
  data1 = {'area': ['a', 'b', 'c', 'a', 'b'],
           'time': [7, 11, 25, 27, 34]}
  data2 = {'area': ['a', 'b', 'c'],
           "count": [2, 2, 3]}
  
  
  df1 = pd.DataFrame(data1)
  df2 = pd.DataFrame(data2)
  
  df = cum_sums(df1)
  print(df)
  print(df2['count'])
  
  df = df.div(df2['count'], axis='columns')
  
  print(df)
  </code></pre>
  
  <p>This produces:</p>
  
  <pre><code>       0   1   2   24
  area                 
  a     0.5 NaN NaN NaN
  b     0.5 NaN NaN NaN
  c     0.0 NaN NaN NaN
  </code></pre>
  
  <p>Where I would expect:</p>
  
  <pre><code>       0  24
  area                 
  a     0.5 1.0 
  b     0.5 1.0
  c     0.0 0.33333
  </code></pre>
  
  <p>I suspect by adding back in missing categories I am changing how the div works but this is speculation. What am I missing in order to get the answer I expect?</p>