Advertisement
Guest User

Untitled

a guest
Jan 18th, 2020
78
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.07 KB | None | 0 0
  1. import pandas as pd
  2.  
  3. ad_data = pd.read_csv('/datasets/ad_data_2.csv')
  4. site_data = pd.read_csv('/datasets/site_data_2.csv')
  5.  
  6. funnel_daily = pd.merge(ad_data, site_data, on='date')
  7. funnel_daily['ctr, %'] = funnel_daily['clicks'] / funnel_daily['impressions'] * 100
  8. funnel_daily['cr, %'] = funnel_daily['registrations'] / funnel_daily['clicks'] * 100
  9.  
  10. funnel_daily['date'] = pd.to_datetime(funnel_daily['date'])
  11. funnel_daily['week'] = funnel_daily['date'].dt.week
  12. funnel_daily['month'] = funnel_daily['date'].dt.month
  13.  
  14. funnel_weekly = funnel_daily.groupby('week')[['impressions', 'clicks', 'registrations']].sum()
  15. funnel_weekly['ctr, %'] = funnel_weekly['clicks'] / funnel_weekly['impressions']*100
  16. funnel_weekly['cr, %'] = funnel_weekly['registrations'] / funnel_weekly['clicks']*100
  17.  
  18. funnel_monthly = funnel_daily.groupby('month')[['impressions', 'clicks', 'registrations']].sum()
  19. funnel_monthly['ctr, %'] = funnel_monthly['clicks'] / funnel_monthly['impressions']*100
  20. funnel_monthly['cr, %'] = funnel_monthly['registrations'] / funnel_monthly['clicks']*100
  21.  
  22. print(funnel_monthly)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement