-
-
Notifications
You must be signed in to change notification settings - Fork 18.4k
COMPAT: restore shape for 'invalid' Index with nd array #27818
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
COMPAT: restore shape for 'invalid' Index with nd array #27818
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@tacaswell will matplotlib be able to track down the places that need updating, to cast Index objects to an ndarray earlier? Would it help if we put an (invisible by default) DeprecationWarning in here?
@@ -111,7 +111,7 @@ Plotting | |||
^^^^^^^^ | |||
|
|||
- Added a pandas_plotting_backends entrypoint group for registering plot backends. See :ref:`extending.plotting-backends` for more (:issue:`26747`). | |||
- | |||
- Fix compatibility issue with matplotlib when passing a pandas ``Index`` to a plot call (:issue:`27775`). |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I like that this is vague about the underlying issue. I don't want people relying on Index.shape being n-d.
What would you deprecate? It's creating the 2D Index that we should deprecate, not necessarily accessing its shape. To be clear, I only see this as a fix for 0.25.1, and we should further discuss how we want to fix this long term on master (convert to ndarray, or deprecate/raise error) |
Not really a deprecation. Just a "hey this is wrong" warning that's invisible by default in |
To be clear, do you propose that instead of this PR? (or as something that should be added to this PR?) (for me that is again part of a separate longer term solution discussion) |
seems ok to me for 0.25.1, I think we should raise starting in 1.0.0 for this on consruction; its invalid. |
Not instead, in addition to. Let's see how the index construction goes. |
@TomAugspurger Yes: matplotlib/matplotlib#15007 although you may get a fix out before we do though 🤷♀️ . |
@jreback What type would you raise? If it is |
Turns out this used to be extra goofy: In [13]: import pandas
In [14]: pandas.__version__
Out[14]: '0.24.2'
In [15]: import pandas as pd
In [16]: df = pd.DataFrame([1, 2])
In [17]: df.index[:, None].shape
Out[17]: (2, 1)
In [18]: df.index[:, None].ndim
Out[18]: 1 |
@tacaswell yes, it was buggy, it is still buggy, we just changed the way it was buggy (and this PR restores the previous way of buggy) But let's keep all that discussion about additional fixes, returning array or erroring, .. for a proper issue about it (I will open one). |
…ex with nd array
Opened an issue here: #27837 |
closes #27775