Skip to content

[EA] ExtensionArray should support ndim==2 #21908

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 Jul 14, 2018 · 6 comments
Closed

[EA] ExtensionArray should support ndim==2 #21908

jbrockmendel opened this issue Jul 14, 2018 · 6 comments

Comments

@jbrockmendel
Copy link
Member

There are a bunch of issues (indirectly) caused by the fact that we can't reshape a DatetimeIndex[tz] as 2D.

#13287, #17539, #19197, and each of the several issues about interpolation with datetime64[tz] dtypes. At the end of DataFrame._init_ndarray is:

        if dtype is None and is_object_dtype(values):
            values = maybe_infer_to_datetimelike(values)

        return create_block_manager_from_blocks([values], [columns, index])

but in the relevant cases, maybe_infer_to_datetimelike returns a tz-aware DatetimeIndex, which create_block_manager_from_blocks raises on because it is expecting values to be 2D.

I cleanest way to fix this seems to be supporting 2D shapes for DatetimeArray (and ideally others for compat)

@jorisvandenbossche
Copy link
Member

We deliberately restricted it to 1D, and I think that is still the good way to go.
For the datetime block related stuff (which is consolidated to 2D) this will mean some workarounds, but in the end we should convert this to 1D extension arrays / extension block as well IMO.

@jbrockmendel
Copy link
Member Author

We deliberately restricted it to 1D, and I think that is still the good way to go.

I'll try to track down this discussion and see the original reasoning. AFAICT the main thing we get out of the 1D restriction is not having to worry about axis arguments, but we're paying for it by sacrificing a lot of the generality people think of with "array"s.

@jreback
Copy link
Contributor

jreback commented Jul 14, 2018

i agree that we should restrict to 1D and just move datetime to EA

@jbrockmendel
Copy link
Member Author

i agree that we should restrict to 1D and just move datetime to EA

We are moving datetime to EA, that is currently in progress. What I'm saying is that there are bugs that are caused by the inability to reshape e.g. dtarr.reshape((N, 1)) and I'm not clear what we get in exchange for that restriction (still looking for the old discussion).

@jorisvandenbossche
Copy link
Member

What I'm saying is that there are bugs that are caused by the inability to reshape

We will need to update the code to handle with 1D instead of 2D, for sure.

AFAICT the main thing we get out of the 1D restriction is not having to worry about axis arguments,

Yes, I think that is one of the main reasons. This fact is one of the things that make the current block manager really complex.

@jbrockmendel
Copy link
Member Author

Fair enough. Closing, will chime in in the appropriate place.

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

No branches or pull requests

3 participants