Skip to content

Instantly share code, notes, and snippets.

@itsderek23
Last active July 5, 2019 16:37
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/eb6cb2c51803de1401c28356e86fb61a to your computer and use it in GitHub Desktop.
Save itsderek23/eb6cb2c51803de1401c28356e86fb61a to your computer and use it in GitHub Desktop.
SERP Analysis - Overperforming Keywords
# df_by_query is from https://gist.github.com/itsderek23/41cd10943201e7b664619c6cd15f409d
# Limit to queries with at least 1 click and in the 60th quartile or greater by position.
# Limit to queries with a CTR > the 0.5% quartile w/at least 1 click. This sounds low, but many queries will have zero clicks.
df_by_query_low_positions = df_by_query[(df_by_query.ctr > 0) & (df_by_query.position >= df_by_query.position.quantile(0.4))]
(df_by_query_low_positions[df_by_query_low_positions.ctr >= df_by_query[df_by_query.ctr > 0].ctr.quantile(0.05)]
.sort_values("impressions",ascending=False).head(10)
)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment