Skip to content

Instantly share code, notes, and snippets.

@abhijeet-talaulikar
Last active September 27, 2023 16:02
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save abhijeet-talaulikar/7c52fe816380b895380d70edd1bb928c to your computer and use it in GitHub Desktop.
Save abhijeet-talaulikar/7c52fe816380b895380d70edd1bb928c 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