ENH: Make categories setitem error more readable #46646
Labels
Categorical
Categorical Data Type
Enhancement
Error Reporting
Incorrect or improved errors from pandas
good first issue
Pandas version checks
I have checked that this issue has not already been reported.
I have confirmed this bug exists on the latest version of pandas.
I have confirmed this bug exists on the main branch of pandas.
Reproducible Example
Issue Description
_validate_scalar
incategorical.py
is propagating an exception that could often lead to confusing error stack-trace because of the previous errors that would have occured. So instead of having the following code:pandas/pandas/core/arrays/categorical.py
Lines 1474 to 1477 in c8cbe19
If it is replace with:
The error stack-trace will be cleaner like as follows:
Expected Behavior
Installed Versions
Replace this line with the output of pd.show_versions()
The text was updated successfully, but these errors were encountered: