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

API: ExtensionArray interface method to create an empty / all-NA array for a given dtype #39776

Open
jorisvandenbossche opened this issue Feb 12, 2021 · 2 comments
Labels
API Design Enhancement ExtensionArray Extending pandas with custom dtypes or arrays.

Comments

@jorisvandenbossche
Copy link
Member

Specific use case comes from #39612 (comment), but in general it can sometimes be useful to be able to create an empty or all-NA array in an efficient way.

Since the ExtensionDtype/Array knows best how to do this efficiently, we can add a method to the extension array interface for this.

One question, though: I mentioned above "empty or all-NA", but this is not the same of course. An actually uninitialized array (np.empty(n, dtype)) can still be faster to create as an all-NA array (np.full(n, NA, dtype), or variant with the appropriate NA-sentinel).

But maybe we don't care much about this distinction, and just a version to create all-NA is fine? (or another constant fill_value)

@jbrockmendel
Copy link
Member

closed by #40602 that implemented EA._empty? #19600 is the analogous issue calling for a EADtype.empy

@jbrockmendel jbrockmendel added the Closing Candidate May be closeable, needs more eyeballs label Dec 21, 2021
@jorisvandenbossche
Copy link
Member Author

See also the discussion in #40602: the current interface does not yet provide a way to get an all-NA array, which is half of this issue (if we decide that's useful enough of course).

I think on the other PR, I mentioned the option of adding a keyword to empty() to ask for all-NAs (and if not asking for it, it can still be all NA (as we do for some implementations), but doesn't need to be guaranteed)

@jorisvandenbossche jorisvandenbossche removed the Closing Candidate May be closeable, needs more eyeballs label Dec 23, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
API Design Enhancement ExtensionArray Extending pandas with custom dtypes or arrays.
Projects
None yet
Development

No branches or pull requests

3 participants