Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

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

Merged
dopplershift merged 1 commit intomatplotlib:masterfromjklymak:fix-reshape-pandas
Aug 30, 2020

Conversation

jklymak
Copy link
Member

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 using
for x in X to get each column of the matrix individually.

That is incompatible with Pandas data frame likedf = 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 usingto_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.

@jklymak
Copy link
MemberAuthor

ping@mwaskom for your opinion.... Thanks!

@mwaskom
Copy link

Seems reasonable for handling pandas objects, but if someone passes in a dictionary (or anything else with a.values method), they might get a pretty confusing error.

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).

@jklymak
Copy link
MemberAuthor

Ok it's pretty easy to also check if values returns an array. I guess I'm just used to values from xarray.

@timhoffm
Copy link
Member

Anybody can merge after CI psss.

@jklymakjklymak removed the request for review fromdstansbyAugust 30, 2020 02:57
@dopplershiftdopplershift merged commitd3eaffd intomatplotlib:masterAug 30, 2020
meeseeksmachine pushed a commit to meeseeksmachine/matplotlib that referenced this pull requestAug 30, 2020
dopplershift added a commit that referenced this pull requestAug 30, 2020
…374-on-v3.3.xBackport PR#18374 on branch v3.3.x (FIX: make _reshape_2D accept pandas df with string indices)
@jklymakjklymak deleted the fix-reshape-pandas branchJanuary 29, 2024 00:33
Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment
Reviewers

@phobsonphobsonphobson approved these changes

@timhoffmtimhoffmtimhoffm approved these changes

@QuLogicQuLogicAwaiting requested review from QuLogic

Assignees
No one assigned
Projects
None yet
Milestone
v3.3.2
Development

Successfully merging this pull request may close these issues.

Plotting a pandas DataFrame with string MultiIndex
5 participants
@jklymak@mwaskom@timhoffm@phobson@dopplershift

[8]ページ先頭

©2009-2025 Movatter.jp