Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Sandy4321/bd8a045005bd5644f808d7047ff0ee46 to your computer and use it in GitHub Desktop.
Save Sandy4321/bd8a045005bd5644f808d7047ff0ee46 to your computer and use it in GitHub Desktop.
df_scatter = df_multi.copy()
df_scatter['Coverage'] = df_scatter['Channel'].map(
campaign_data.groupby('channel')['customer_id'].nunique().to_dict()
)
df_scatter['Total Clicks'] = df_scatter['Channel'].map(
journeys['path'].apply(lambda x: x[-2]).value_counts().to_dict()
)
df_scatter['Activation Clicks'] = df_scatter['Channel'].map(
journeys.loc[
journeys.path.apply(lambda x: x[-1]) == 'Activation',
'path'
].apply(lambda x: x[-2]).value_counts().to_dict()
)
df_scatter['Attribution'] = df_scatter['Activations'] / df_scatter['Activations'].sum()
df_scatter['Activation Rate'] = df_scatter['Activations'] / df_scatter['Coverage']
df_scatter['Click Activation Rate'] = df_scatter['Activation Clicks'] / df_scatter['Total Clicks']
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment