| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
|
Is this function used anywhere else then with bars? Should bar also support dataframes, like df = pd.DataFrame({0:[1,2,3]},index=[1,2,3])
This works with plt.scatter(df, [3,4,5]), but probably not with plt.bar(df, [3,4,5]), right? |
Sorry, something went wrong.
|
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 (TypeError: float() argument must be a string or a number, not 'NoneType' on 3.0.0). The error with this PR if the data name is called 0 is a bit more mysterious, but that's a relatively perverse data frame (I hope). |
Sorry, something went wrong.
|
Ok, just take df = pd.DataFrame([1,2,3]) then. I think it would be good to define whether single-column dataframes are supposed to work or not. They do for scatter/plot, so one might expect that, but if they don't, maybe a message that is a bit more helpful than "Your linewidth is wrong" would be useful. |
Sorry, something went wrong.
|
This PR is trying to fix something I broke, not expand the duck typing for bar. |
Sorry, something went wrong.
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....
Sorry, something went wrong.
|
Owee, I'm MrMeeseeks, Look at me. There seem to be a conflict, please backport manually. Here are approximate instructions:
$ git checkout v3.1.x $ git pull
$ git cherry-pick -m1 e67c2fbfc257a1f3414eebfe873b78552ba9a7f3
$ git commit -am 'Backport PR #15166: FIX: indexed pandas bar'
git push YOURFORK v3.1.x:auto-backport-of-pr-15166-on-v3.1.x
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. |
Sorry, something went wrong.
FIX: indexed pandas bar
Backport PR #15166 on branch v3.1.x
Sorry, something went wrong.
| Back | FazBrowse Home | New Git URL |
PR Summary
Closes #15162
basically if you do df = pd.DataFrame({"x":[1,2,3],"width":[.2,.4,.6]},index=[1,2,3]), then df.x[0] errors because that index doesn't exist, which breaks bar.
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 presuppose iat exists.
Now yields the expected (and pre 3.1.0):
PR Checklist