Skip to content
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

BUG: disallow scalar in CategoricalIndex construtor #38614

Merged
merged 4 commits into from
Dec 23, 2020

Conversation

jbrockmendel
Copy link
Member

@jbrockmendel jbrockmendel commented Dec 21, 2020

  • closes #xxxx
  • tests added / passed
  • passes black pandas
  • passes git diff upstream/master -u -- "*.py" | flake8 --diff
  • whatsnew entry

@jreback jreback added the Categorical Categorical Data Type label Dec 22, 2020
@jreback
Copy link
Contributor

jreback commented Dec 22, 2020

i guess need to deprecate here as well (unless you use the Categorical for constrution)

@jbrockmendel
Copy link
Member Author

i guess need to deprecate here as well

i think this is pretty unambiguously a bug

@jreback
Copy link
Contributor

jreback commented Dec 22, 2020

i guess need to deprecate here as well

i think this is pretty unambiguously a bug

oh right yeah its a scalar in an Index, ok

@jreback jreback added this to the 1.3 milestone Dec 22, 2020
@jreback
Copy link
Contributor

jreback commented Dec 22, 2020

ok i guess add a whatsnew here to document

@jbrockmendel
Copy link
Member Author

whatsnew added + greenish

@jreback jreback merged commit 019d053 into pandas-dev:master Dec 23, 2020
@jbrockmendel jbrockmendel deleted the bug-ci-scalar branch December 23, 2020 16:01
# 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 = []
Copy link
Member

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)

Copy link
Member

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Categorical Categorical Data Type
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants