From 0c940e7aba124ecd519327c154f32d7990e31165 Mon Sep 17 00:00:00 2001 From: Partho Date: Mon, 15 Aug 2022 21:12:10 +0530 Subject: [PATCH] ENH: Make categories setitem error more readable --- pandas/core/arrays/categorical.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pandas/core/arrays/categorical.py b/pandas/core/arrays/categorical.py index b50ddd42997cb..0d228582992d2 100644 --- a/pandas/core/arrays/categorical.py +++ b/pandas/core/arrays/categorical.py @@ -1588,7 +1588,7 @@ def _validate_scalar(self, fill_value): raise TypeError( "Cannot setitem on a Categorical with a new " f"category ({fill_value}), set the categories first" - ) + ) from None return fill_value # -------------------------------------------------------------