From 857296e88c70c31a82fd150a8fdf7cad53ae5822 Mon Sep 17 00:00:00 2001 From: "Eric O. LEBIGOT (EOL)" Date: Tue, 15 Aug 2017 21:48:28 +0200 Subject: [PATCH] More Pandaesque way of getting the mode of a Series The grouping is 3 times faster, with the dedicated `mode()` method. --- modern_3_indexes.ipynb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modern_3_indexes.ipynb b/modern_3_indexes.ipynb index 8d59efa..f6c7164 100644 --- a/modern_3_indexes.ipynb +++ b/modern_3_indexes.ipynb @@ -2376,7 +2376,7 @@ " '''\n", " Arbitrarily break ties.\n", " '''\n", - " return x.value_counts().index[0]\n", + " return x.mode().iloc[0]\n", "\n", "aggfuncs = {'tmpf': 'mean', 'relh': 'mean',\n", " 'sped': 'mean', 'mslp': 'mean',\n",