Skip to content
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

DataFrame.plot.box ignores by argument #15079

Closed
ischurov opened this issue Jan 7, 2017 · 7 comments · Fixed by #28373
Closed

DataFrame.plot.box ignores by argument #15079

ischurov opened this issue Jan 7, 2017 · 7 comments · Fixed by #28373
Milestone

Comments

@ischurov
Copy link
Contributor

ischurov commented Jan 7, 2017

Code Sample, a copy-pastable example if possible

df = pd.DataFrame({'a': ['one', 'one', 'two', 'one', 'two', 'two'], 
                   'b': [1, 2, -1, 2, -2, -3]})
df.boxplot(by='a')
# two boxplots, one for 'one' and the other for 'two'
# this is an expected behaviour

boxplot-ok

df.plot(kind='box', by='a')
# one boxplot, grouping ignored

boxplot-kind

df.plot.box(by='a')
# one boxplot, grouping ignored

boxplot-plot-box

Problem description

It seems that by argument is silently ignored and no grouping occurs. Probably, it is related to #9274.

Expected Output

I expect that three figures will be the same as the first one.

Output of pd.show_versions()

INSTALLED VERSIONS ------------------ commit: None python: 3.5.2.final.0 python-bits: 64 OS: Darwin OS-release: 16.3.0 machine: x86_64 processor: i386 byteorder: little LC_ALL: en_US.UTF-8 LANG: en_US.UTF-8 LOCALE: en_US.UTF-8

pandas: 0.19.0+311.gb895968
nose: 1.3.7
pip: 9.0.1
setuptools: 27.2.0
Cython: 0.25.1
numpy: 1.11.2
scipy: None
statsmodels: None
xarray: None
IPython: 5.1.0
sphinx: 1.5.1
patsy: None
dateutil: 2.6.0
pytz: 2016.10
blosc: None
bottleneck: None
tables: None
numexpr: None
feather: None
matplotlib: 1.5.3
openpyxl: None
xlrd: None
xlwt: None
xlsxwriter: None
lxml: None
bs4: None
html5lib: 0.9999999
httplib2: None
apiclient: None
sqlalchemy: None
pymysql: None
psycopg2: None
jinja2: 2.8
s3fs: None
pandas_datareader: None

@bkandel
Copy link
Contributor

bkandel commented Jan 9, 2017

This is also related to #7998. I thought that the code for DataFrame.boxplot, DataFrame.plot(kind=box), and DataFrame.plot.box were the same, but apparently not. It looks like the by arg was never implemented for the plot(kind=box) method: https://github.com/pandas-dev/pandas/blob/master/pandas/tools/plotting.py#L2794 doesn't have any counterpart in https://github.com/pandas-dev/pandas/blob/master/pandas/tools/plotting.py#L2287.

@TomAugspurger
Copy link
Contributor

@ischurov is this any different that #9274? It seems like the same issue to me.

@bkandel
Copy link
Contributor

bkandel commented Jan 10, 2017

I don't think it's the same -- from the discussion there, it looks like #9274 is about documenting that by only works when kind='box'. But here the bug report is that by doesn't actually work when kind='box'. So this is a bug report, not a request for additional documentation.

@ischurov
Copy link
Contributor Author

@TomAugspurger , I agree with @bkandel 's comment.

@blokeley
Copy link

The Stack Overflow question got no answers. It seems to be a bug.

@jorisvandenbossche
Copy link
Member

jorisvandenbossche commented Mar 14, 2018

I actually think this is the same issue. by is documented for several df.plot.<methods> like df.plot.box, df.plot.hist. But, this was never implemented and only the df.hist and df.boxplot methods actually support this (those methods have a complete separate implementation).

Ideally on the long term the implementation of df.hist and df.boxplot would get integrated into the df.plot. kinds, and then they could support by, but for now, let's fix the documentation.

@Jeitan
Copy link

Jeitan commented Sep 9, 2019

@jorisvandenbossche I would LOVE to see by implemented in plot.hist and have made a comment along those lines at #28177 . Seeing as how that's what the documentation has been saying all along...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

8 participants