Skip to content

ExtensionDtype.construct_array_type is not optional #24860

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
jorisvandenbossche opened this issue Jan 21, 2019 · 5 comments · Fixed by #41862
Closed

ExtensionDtype.construct_array_type is not optional #24860

jorisvandenbossche opened this issue Jan 21, 2019 · 5 comments · Fixed by #41862
Labels
ExtensionArray Extending pandas with custom dtypes or arrays.

Comments

@jorisvandenbossche
Copy link
Member

Currently, the ExtensionDtype docstring says:

Optionally one can override construct_array_type for construction
with the name of this dtype via the Registry. See
:meth:`pandas.api.extensions.register_extension_dtype`.

* construct_array_type

However, it seems that in practice this is used for more than just supporting string dtypes. Eg I also need to implement it to have groupby working.

Eg cyberpandas does not yet implement it, and there df.groupby('ipaddresses').size() fails with a NotImplementedError.

I assume we are fine with requiring this (assuming a 1-1 mapping of dtype and array), and a doc update is enough?

@jorisvandenbossche jorisvandenbossche added the ExtensionArray Extending pandas with custom dtypes or arrays. label Jan 21, 2019
@jreback
Copy link
Contributor

jreback commented Jan 21, 2019

yeah this should probably be a required element of an EA Dtype

@TomAugspurger
Copy link
Contributor

TomAugspurger commented Jan 21, 2019 via email

@jbrockmendel
Copy link
Member

I see the usefulness here, but there is a non-trivial downside that this prevents core.dtypes from being self-contained (w/r/t the rest of core).

@jbrockmendel
Copy link
Member

I'm now fully on board with this. Is it just a matter of updating the docstring?

@jorisvandenbossche
Copy link
Member Author

And I suppose changing the implementation from NotImplementedError to AbstractMethodError ?

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

Successfully merging a pull request may close this issue.

4 participants