-
-
Notifications
You must be signed in to change notification settings - Fork 18.4k
BUG: disallow scalar in CategoricalIndex construtor #38614
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
i guess need to deprecate here as well (unless you use the Categorical for constrution) |
i think this is pretty unambiguously a bug |
oh right yeah its a scalar in an Index, ok |
ok i guess add a whatsnew here to document |
whatsnew added + greenish |
# if data is None, then categories must be provided | ||
if data is not None or categories is None: | ||
raise cls._scalar_data_error(data) | ||
data = [] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is not actually about passing scalar data, but about passing no data (eg pd.CategoricalIndex(categories=['a', 'b'])
). We generally support constructors with passing no data to create an empty (eg Series also allows this).
So I would either keep supporting this, or either it should at least be deprecated (this eg breaks dask)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Opened #38944 to track this
black pandas
git diff upstream/master -u -- "*.py" | flake8 --diff