-
-
Notifications
You must be signed in to change notification settings - Fork 18.4k
ENH/VIZ: Allowing s
parameter of scatter plots to be a column name
#33107
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
ENH/VIZ: Allowing s
parameter of scatter plots to be a column name
#33107
Conversation
s
parameter of scatter plots to be a column name
s
parameter of scatter plots to be a column names
parameter of scatter plots to be a column name
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.
lgtm, thanks @SultanOrazbayev
@TomAugspurger if you want to have a look...
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.
Can you update the plot.scatter docstring to indicate that a column label is also accepted, and a ..versionchanged 1.1.0
noting that labels are accepted starting in 1.1.0?
pandas/tests/plotting/test_frame.py
Outdated
# this refers to GH 32904 | ||
df = DataFrame(np.random.random((10, 3)) * 100, columns=["a", "b", "c"],) | ||
|
||
_check_plot_works(df.plot.scatter, x="a", y="b", s="c") |
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.
It would be good to have some assertion here that the argument actually had an effect. Perhaps something like
_check_plot_works(df.plot.scatter, x="a", y="b", s="c") | |
ax = df.plot.scatter(x="a", y="b", s="c") | |
assert len(set(ax.collections[0].get_sizes())) > 1 |
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.
Actually, I'm confused about the correct way of using versionchanged
. I read https://www.sphinx-doc.org/en/master/usage/restructuredtext/directives.html and I think this is suitable:
However, not sure about the indentation and whether second argument to versionchanged
is needed (searching pandas code shows that sometimes the description is added, but it's not everywhere).
Thanks @SultanOrazbayev. Congrats on your first PR to pandas! |
Thank you very much for your help! Glad it worked out! |
black pandas
git diff upstream/master -u -- "*.py" | flake8 --diff
This PR is a continuation of #32937 (made an error when pulling changes from the master).
I had a more elaborate decision tree for what to do with a passed size variable
s
, here #32937, but in the end decided to go with the simpler version since the other checks are redundant (they would contains=s
orpass
).