-
-
Notifications
You must be signed in to change notification settings - Fork 18k
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
PeriodIndex.ravel returns ndarray[int64] #19956
Comments
That seems consistent with the docstring? |
Sure, but it's not exactly useful behavior. |
Why not? |
The relevant context is the ongoing effort to ensure that Index/Series/DataFrame operations are consistent with one another. The Index vs Series part is most of the way there, and I'm just starting in on Series vs DataFrame. In core.ops, Series and DataFrame arithmetic operations have really similar error catching logic: Series:
DataFrame:
Very nearly the only differences here are a) |
Ah, interesting...got it. Well, this is an API change, so I'll open it up to @jreback @jorisvandenbossche . Is there any reason why we always returned |
@TomAugspurger possibly change this behavior in a follow up to PeriodArray? |
Is the expected behavior an ndarray[object] with period object? This could be done any time by defining PeriodIndex.ravel as |
For PeriodArray I’d expect it to return a 1-dim-reshaped view on itself. So a no-op for EA since those are 1-dim to begin with. |
That'll need a larger discussion then, since the other EA-backed indexes all return ndarrays for ravel. |
Also for Series, I think there is also something to be said for The question is: what do people use it for? It might be that it is used in cases where afterwards the code expects to now have a numpy array. |
The place that motivated this issue is in |
And what's the reason we call it there? What do we want to end up with there? |
In that case we are calling |
And what do you mean with 'array-like' in this case? I assume we know what types it can be? |
https://github.com/pandas-dev/pandas/blob/master/pandas/core/ops.py#L842
|
But if the object is array, Series or Index, why do we want to ravel? Because all those are already 1D? (or the array can be 2D?) |
I think just checking |
Anyway, mainly what I am trying to ask about: in this specific case that motivated the proposal, there might be a very easy way to also avoid duplicated code, without needing |
Well, so exactly what @TomAugspurger said :-) |
The array can be 2D.
This is fine. The extant code also works fine.
That is pretty much what the Issue is about. We can certainly stick a pin in this, but long-term the method's behavior should match the standard usage of the term "ravel" |
Yeah, we'll certainly need to resolve this, but I think it depends a bit on
the result of #19954, if you have any thoughts there.
…On Fri, Oct 26, 2018 at 9:37 AM jbrockmendel ***@***.***> wrote:
But if the object is array, Series or Index, why do we want to ravel?
Because all those are already 1D? (or the array can be 2D?)
The array can be 2D.
I think just checking if y.ndim > 1: yrav = y.ravel() is the way to go.
This is fine. The extant code also works fine.
but it avoids the discussion of what "ravel" means for EA-backed Series
That is pretty much what the Issue is about. We can certainly stick a pin
in this, but long-term the method's behavior should match the standard
usage of the term "ravel"
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#19956 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/ABQHIkZ77ozJxSuwAAPXD2QtdZz1jQHeks5uox4ngaJpZM4SY1EH>
.
|
This deprecation was done in 1.2; closing. |
But did we ever follow-up on the discussion in #36900? The deprecation warning still says that in the future it will return a view on self. Which still creates an inconsistency with Series. |
I see the appeal of being consistent with Series, but dont like the idea of materializing RangeIndex/MultiIndex. |
This came up while trying to de-duplicate some DataFrame vs Series arithmetic logic in core.ops.
The text was updated successfully, but these errors were encountered: