title: Groupby and interpolate in Pandas
body: <p>I have data that has a week number, account id, and several usage columns. I'd like to a) group by account ID, b) resample weekly data into daily, and c) interpolate daily data evenly (divide the weekly by 7), then bring it all back together. I've got most of it down, but Pandas <code>groupby</code> confuses me a little. It's also very slow, which makes me think this might not be the optimal solution.</p>
  
  <p>Data looks like this:</p>
  
  <pre><code>    Account Id  year week         views stats foo_col 
  31133   213     2017-03-05          4.0     2.0     11.0
  10085   456     2017-03-12          1.0     6.0     3.0
  49551   789     2017-03-26          1.0     6.0     27.0
  </code></pre>
  
  <p>Here's my code:</p>
  
  <pre><code>def interpolator(mini_df):
      mini_df = mini_df[cols_to_interpolate].set_index('year week')
      return mini_df.resample('D').ffill().interpolate() / 7
  
  example = list(grp)[0][1]
  interpolator(example) # This works perfectly
  
  df.groupby('Account Id').agg(interpolator)                # doesn't work
  df.groupby('Account Id').transform(interpolator)          # doesn't work
  
  for name,group in grp:
      group = group[cols_to_interpolate].set_index('year week')
      group = group.resample('D').ffill().interpolate() / 7 # doesn't work
  
  for acc_id in df['Account Id'].unique():
      mask = df.loc[df['Account Id'] == acc_id]
      print(df[mask])                                     # doesn't work
  </code></pre>