Forked from abhijeet-talaulikar/mta-credit-card-barchart.py
Created
September 27, 2023 16:03
-
-
Save Sandy4321/eb1f09ab93eebbac95f3b94d232466b9 to your computer and use it in GitHub Desktop.
Revisions
-
abhijeet-talaulikar created this gist
Aug 21, 2023 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,42 @@ df_multi = pd.DataFrame({ 'Channel': attributions.keys(), 'Attribution style': 'Journey', 'Activations': attributions.values() }) df_first = pd.DataFrame({ 'Channel': attributions.keys(), 'Attribution style': 'First touchpoint' }) df_first['Activations'] = df_first['Channel'].map( journeys.loc[ journeys.path.apply(lambda x: x[-1]) == 'Activation', 'path' ].apply(lambda x: x[1]).value_counts().to_dict() ) df_last = pd.DataFrame({ 'Channel': attributions.keys(), 'Attribution style': 'Last touchpoint' }) df_last['Activations'] = df_last['Channel'].map( journeys.loc[ journeys.path.apply(lambda x: x[-1]) == 'Activation', 'path' ].apply(lambda x: x[-2]).value_counts().to_dict() ) df_plot = pd.concat([df_multi, df_first, df_last], axis=0) sns.set_style("darkgrid", {"axes.facecolor": ".9"}) color_codes = ['#2653de','#6989EA','#98AEF0'] sns.catplot( data=df_plot, kind="bar", x="Channel", y="Activations", hue="Attribution style", palette=sns.color_palette(color_codes), height=6, aspect=12/8 )