ENH: Make categories setitem error more readable
Closes #46646
Hello @siddartha-10! Thanks for updating this PR. We checked the lines you've touched for [PEP 8](https://www.python.org/dev/peps/pep-0008) issues, and found:

* In the file [`pandas/core/arrays/categorical.py`](https://github.com/pandas-dev/pandas/blob/6cfec740b731a557f0fe8f37deaa21ed3d60e196/pandas/core/arrays/categorical.py):

> [Line 1477:29](https://github.com/pandas-dev/pandas/blob/6cfec740b731a557f0fe8f37deaa21ed3d60e196/pandas/core/arrays/categorical.py#L1477): [W291](https://duckduckgo.com/?q=pep8%20W291) trailing whitespace
> [Line 1478:13](https://github.com/pandas-dev/pandas/blob/6cfec740b731a557f0fe8f37deaa21ed3d60e196/pandas/core/arrays/categorical.py#L1478): [E122](https://duckduckgo.com/?q=pep8%20E122) continuation line missing indentation or outdented
> [Line 1478:58](https://github.com/pandas-dev/pandas/blob/6cfec740b731a557f0fe8f37deaa21ed3d60e196/pandas/core/arrays/categorical.py#L1478): [W291](https://duckduckgo.com/?q=pep8%20W291) trailing whitespace
> [Line 1479:13](https://github.com/pandas-dev/pandas/blob/6cfec740b731a557f0fe8f37deaa21ed3d60e196/pandas/core/arrays/categorical.py#L1479): [E122](https://duckduckgo.com/?q=pep8%20E122) continuation line missing indentation or outdented
> [Line 1479:65](https://github.com/pandas-dev/pandas/blob/6cfec740b731a557f0fe8f37deaa21ed3d60e196/pandas/core/arrays/categorical.py#L1479): [W291](https://duckduckgo.com/?q=pep8%20W291) trailing whitespace



##### Comment last updated at 2022-07-07 12:27:07 UTC > Thanks for the pr @siddartha-10. Can you please explain the rationale behind this change? Is there a related issue?

Yes @mzeitlin11 There is a issue #46646. Before this it was showing lot of error statements after this it just shows a few of them I believe  > Yes @mzeitlin11 There is a issue #46646. Before this it was showing lot of error statements after this it just shows a few of them I believe

Thanks. Can you please add a test showing how this fixes the issue in #46646. See https://pandas.pydata.org/docs/development/contributing.html for some guidance on how to add a test. Looks like there is also a linting error, please see https://pandas.pydata.org/docs/development/contributing_codebase.html#pre-commit for how to fix that This pull request is stale because it has been open for thirty days with no activity. Please [update](https://pandas.pydata.org/pandas-docs/stable/development/contributing.html#updating-your-pull-request) and respond to this comment if you're still interested in working on this. Thanks for the pull request, but it appears to have gone stale. We have another active contribution in https://github.com/pandas-dev/pandas/pull/48087, so closing in favor.