Advertisement
Dodma

Untitled

Jun 18th, 2020
130
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.44 KB | None | 0 0
  1. monthly_costs_sources = costs.groupby(['month', 'source_id']).agg({'costs':'sum'}).reset_index()
  2. new_for_romi = pd.merge(new, monthly_costs_sources, left_on=['first_order_month', 'source_id'], right_on=['month', 'source_id'])
  3. new_for_romi['cac'] = new_for_romi['costs'] / new_for_romi['cohort_users']
  4. new_for_romi.pivot_table(
  5. index='first_order_month',
  6. columns='cohort_lifetime',
  7. values='cac',
  8. aggfunc='sum')
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement