From 62e2cdb128c9dbfdac4f439bec032071abf7fb40 Mon Sep 17 00:00:00 2001
From: Chandrasekhar Ramakrishnan <cramakri@ethz.ch>
Date: Sun, 12 Apr 2020 21:13:23 +0000
Subject: [PATCH] refactor: simplify countries_over_thresh selection logic

---
 notebooks/Dashboard.ipynb | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/notebooks/Dashboard.ipynb b/notebooks/Dashboard.ipynb
index e586a932c..fc0713e12 100644
--- a/notebooks/Dashboard.ipynb
+++ b/notebooks/Dashboard.ipynb
@@ -74,8 +74,8 @@
     "nthresh = 500\n",
     "\n",
     "# Identify countries with {nthresh} or more cases\n",
-    "country_df = jhu_df.groupby('country')\n",
-    "countries_over_thresh = country_df.max()[country_df.max()['positive']>nthresh]['region_label']\n",
+    "country_max_ser = jhu_df.set_index(['region_label', 'date'])['positive'].groupby(level='region_label').max()\n",
+    "countries_over_thresh = country_max_ser[country_max_ser>nthresh].index\n",
     "\n",
     "# Filter out some countries with very high case/population ratio\n",
     "countries_over_thresh = [c for c in countries_over_thresh if c not in set(['Andorra', 'Iceland', 'San Marino'])]"
-- 
GitLab