Conversation
d472ac8 to
10770e9
Compare
|
Is this function used anywhere else then with bars? Should bar also support dataframes, like This works with |
|
I don't think df = pd.DataFrame({'boo':[1,2,3]},index=[1,2,3])
plt.figure()
plt.bar(df, 1, width=.2)ever worked ( |
|
Ok, just take |
|
This PR is trying to fix something I broke, not expand the duck typing for bar. |
Use `safe_first_element` from cbook which does the `next(iter(x))` dance to get the first element of an object (as defined by what you get when you iterate over it).
| # wrap numpy arrays. | ||
| try: | ||
| x0 = x0[0] | ||
| x0 = cbook.safe_first_element(x0) |
There was a problem hiding this comment.
This is great! Should have checked cbook....
|
Owee, I'm MrMeeseeks, Look at me. There seem to be a conflict, please backport manually. Here are approximate instructions:
And apply the correct labels and milestones. Congratulation you did some good work ! Hopefully your backport PR will be tested by the continuous integration and merged soon! If these instruction are inaccurate, feel free to suggest an improvement. |
FIX: indexed pandas bar
Backport PR #15166 on branch v3.1.x
PR Summary
Closes #15162
basically if you do
df = pd.DataFrame({"x":[1,2,3],"width":[.2,.4,.6]},index=[1,2,3]), thendf.x[0]errors because that index doesn't exist, which breaksbar.While I appreciate this is a bit more code than trying to call
iat(0), which is what we did before, this solution doesn't presupposeiatexists.Now yields the expected (and pre 3.1.0):
PR Checklist