From 79b3d451b9867d2428c3e56fff023c163079b147 Mon Sep 17 00:00:00 2001 From: Simon Hawkins Date: Fri, 27 Aug 2021 13:11:57 +0100 Subject: [PATCH] code sample for #43232 --- bisect/43232.py | 14 ++++++++++++++ 1 file changed, 14 insertions(+) create mode 100644 bisect/43232.py diff --git a/bisect/43232.py b/bisect/43232.py new file mode 100644 index 0000000000000..e46f4e8be9c4d --- /dev/null +++ b/bisect/43232.py @@ -0,0 +1,14 @@ +# BUG: reorder_categories with inplace=True is not changing the dtype.categories #43232 + +import pandas as pd + +print(pd.__version__) + +sr = pd.Series(["a", "b", "c"], dtype="category") + +sr.cat.reorder_categories(["c", "b", "a"], inplace=True) +print(sr) + +result = sr.dtype.categories +expected = pd.Index(["c", "b", "a"], dtype="object") +pd.testing.assert_index_equal(result, expected)