SHARE
TWEET

Untitled

a guest Jul 18th, 2019 66 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. # for each query, find min & max date
  2. df_by_query_date = df.groupby("query").aggregate({"date": ["min","max"], "clicks": "sum",
  3.                               "impressions": "sum", "position": "mean"}).sort_values(("impressions","sum"),ascending=False)
  4. # filter to just queries in above the median in impressions
  5. df_by_query_date = df_by_query_date[df_by_query_date[("impressions","sum")] >= df_by_query_date[("impressions","sum")].quantile(0.50)]
  6. # find all queries that haven't appeared in the last two weeks
  7. df_by_query_date[df_by_query_date[("date","max")] < datetime.datetime.now() - datetime.timedelta(days=14)].head(5)
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Not a member of Pastebin yet?
Sign Up, it unlocks many cool features!
 
Top