Skip to content

Instantly share code, notes, and snippets.

@hamletbatista
Created February 28, 2019 22:15
Show Gist options
  • Save hamletbatista/8ad1128c88521dc51e0d12655b1ff986 to your computer and use it in GitHub Desktop.
Save hamletbatista/8ad1128c88521dc51e0d12655b1ff986 to your computer and use it in GitHub Desktop.
# Comparing pages from before and after the switch
true_change = true_totals_after.merge(true_totals_before,
left_on="true_url",
right_on="true_url",
suffixes=["_after", "_before"],
how="outer")
true_change.loc[:, ["ga:newUsers_after", "ga:newUsers_before"]].fillna(0, inplace=True)
true_change['difference'] = true_change['ga:newUsers_after'] - true_change['ga:newUsers_before']
true_change['percent_change'] = true_change['difference'] / true_change['ga:newUsers_before']
true_winners = true_change[true_change['percent_change'] > 0]
true_losers = true_change[true_change['percent_change'] < 0]
true_no_change = true_change[true_change['percent_change'] == 0]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment