Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork7.9k
FIX: make _reshape_2D accept pandas df with string indices#18374
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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.
Already on GitHub?Sign in to your account
Uh oh!
There was an error while loading.Please reload this page.
Conversation
7f98aae
to27a81eb
Compareping@mwaskom for your opinion.... Thanks! |
mwaskom commentedAug 29, 2020
Seems reasonable for handling pandas objects, but if someone passes in a dictionary (or anything else with a I guess matplotlib doesn't in general support dict inputs so that's maybe not a risk, although boxplots are an obvious place to do so (each entry in the dict becomes a box over its values vector at the location of its key). |
Ok it's pretty easy to also check if values returns an array. I guess I'm just used to values from xarray. |
Anybody can merge after CI psss. |
…with string indices
…374-on-v3.3.xBackport PR#18374 on branch v3.3.x (FIX: make _reshape_2D accept pandas df with string indices)
Closes#18371
In#17289 we changed
_reshape_2D
(used byviolinplot
andboxplot
). It used to basically just callnp.asanyarray(X)
which works fine with pandas. However, there is a ragged array deprecation, so#17289 now iterates over the columns usingfor x in X
to get each column of the matrix individually.That is incompatible with Pandas data frame like
df = pd.DataFrame(np.random.randn(100, 3), columns=["a", "b", "c"])
, which return the error in#18371, which is a regression.Here we try to extract the matrix from X using
to_numpy()
orvalues
before doing the rest of the manipulations.Note this still doesn't do the "right thing" for the column names, at least using box plot, but this fixes the regression. If the folks who use boxplot or violinplot want to do something fancier with the column names they can try to make that work in some reasonable way, but I think such fancy pandas handling really belongs in pandas, or perhaps the structured data refactor.