Skip to content

CategoricalBlock.array_dtype out of date? #22381

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

Closed
jbrockmendel opened this issue Aug 16, 2018 · 2 comments
Closed

CategoricalBlock.array_dtype out of date? #22381

jbrockmendel opened this issue Aug 16, 2018 · 2 comments
Labels
ExtensionArray Extending pandas with custom dtypes or arrays.

Comments

@jbrockmendel
Copy link
Member

CategoricalBlock.array_dtype returns np.object_, but the docstring describes array_dtype as "the dtype to return if I want to construct this block as an array". Shouldn't the array constructed now be Categorical? In which case, shouldn't the dtype here be self.dtype? (which matches the base class, and in fact makes the attribute unnecessary)

@jorisvandenbossche
Copy link
Member

Depends on what kind of array? (numpy ndarray or EA?)

The only place where I see this used in internals is

blocks = np.array([], dtype=self.array_dtype)

where in any case it is required to be a numpy dtype (and not extension dtype). So apparently this path is not hit with ExtensionBlock (where array_dtype is an EAdtype, otherwise it would fail). So from that, I think Categorical is actually more correct, apart from that it doesn't seem used anyway.

It would be good to investigate which path hits it, and see if it is possible to get there with an extension array.

@jorisvandenbossche jorisvandenbossche added the ExtensionArray Extending pandas with custom dtypes or arrays. label Aug 16, 2018
@jbrockmendel
Copy link
Member Author

Depends on what kind of array? (numpy ndarray or EA?)

Yah, a lot of things seem to have this characteristic. This is part of the motivation for #22388.

So from that, I think Categorical is actually more correct, apart from that it doesn't seem used anyway.

Agreed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
ExtensionArray Extending pandas with custom dtypes or arrays.
Projects
None yet
Development

No branches or pull requests

2 participants