From 7a29ca42dab28c3c895bfc31cde53831f6126357 Mon Sep 17 00:00:00 2001 From: Armin Berres Date: Fri, 19 Feb 2021 10:55:41 +0100 Subject: [PATCH] Add a missing sort_index() to ensure category order matches the returned series value_counts() does not return with a sorted index, hence the plot's labels were random. --- 09_tabular.ipynb | 2 +- clean/09_tabular.ipynb | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/09_tabular.ipynb b/09_tabular.ipynb index 34e4b26..644812b 100644 --- a/09_tabular.ipynb +++ b/09_tabular.ipynb @@ -8596,7 +8596,7 @@ } ], "source": [ - "p = valid_xs_final['ProductSize'].value_counts(sort=False).plot.barh()\n", + "p = valid_xs_final['ProductSize'].value_counts(sort=False).sort_index().plot.barh()\n", "c = to.classes['ProductSize']\n", "plt.yticks(range(len(c)), c);" ] diff --git a/clean/09_tabular.ipynb b/clean/09_tabular.ipynb index 04b952a..78d6cd3 100644 --- a/clean/09_tabular.ipynb +++ b/clean/09_tabular.ipynb @@ -866,7 +866,7 @@ "metadata": {}, "outputs": [], "source": [ - "p = valid_xs_final['ProductSize'].value_counts(sort=False).plot.barh()\n", + "p = valid_xs_final['ProductSize'].value_counts(sort=False).sort_index().plot.barh()\n", "c = to.classes['ProductSize']\n", "plt.yticks(range(len(c)), c);" ]