Skip to content

Instantly share code, notes, and snippets.

@itsderek23
Created July 5, 2019 15:29
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 itsderek23/2d8d705c18f3076ee579f1a047ebc6b5 to your computer and use it in GitHub Desktop.
Save itsderek23/2d8d705c18f3076ee579f1a047ebc6b5 to your computer and use it in GitHub Desktop.
SERP Analysis - Plot Click Through Rate (CTR) by Position
df_by_position = df.groupby(df.position.apply(lambda x: round(x, 0))).agg({
"clicks": "sum", "impressions": "sum"
})
df_by_position['ctr'] = (df_by_position.clicks / df_by_position.impressions)*100
df_by_position[df_by_position.index <= 20].ctr.plot(title="Click Through Rate (CTR) by Position")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment