-
-
Notifications
You must be signed in to change notification settings - Fork 18.4k
warning in bar plot with multiple columns #18764
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
Comments
Can you check if this was fixed by #18695? |
Actually, #18695 breaks my plot entirely by only allowing >>> import numpy as np
>>> import pandas as pd
>>> pd.__version__
'0.22.0.dev0+356.g9705a4806'
>>> a = np.random.randint(1, 100, size=10)
>>> b = 100 - a
>>> i = np.arange(100, 110)
>>>
>>> df = pd.DataFrame(dict(a=a, b=b, i=i))
>>> df.plot.bar(x='i', y=['b','a'], stacked=True)
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/Users/adefusco/Development/Continuum/pandas/pandas/plotting/_core.py", line 2701, in bar
return self(kind='bar', x=x, y=y, **kwds)
File "/Users/adefusco/Development/Continuum/pandas/pandas/plotting/_core.py", line 2666, in __call__
sort_columns=sort_columns, **kwds)
File "/Users/adefusco/Development/Continuum/pandas/pandas/plotting/_core.py", line 1905, in plot_frame
**kwds)
File "/Users/adefusco/Development/Continuum/pandas/pandas/plotting/_core.py", line 1716, in _plot
raise ValueError("y must be a label or position")
ValueError: y must be a label or position |
Yeah, that was the point of #18695, to raise when the user passes invalid arguments. If you want to plot multiple, I'd recommend |
Ok, thanks. |
Code Sample, a copy-pastable example if possible
Problem description
The warning message about
series.name = label
in this case is because it's trying to do the following. I am not using thelabel
keyword argument.and since
series
is actually a Pandas now thinks that a new column is being created with the values['a','b']
.Expected Output
The warning message does not occur if the Index is used as the x-axis
Proposed solution
In
pandas/plotting/_core.py
would the following be reasonable?this provides for the following options using the DataFrame defined above.
After I teach myself how to build Pandas I'll test this change.
Output of
pd.show_versions()
INSTALLED VERSIONS
commit: None
python: 3.6.3.final.0
python-bits: 64
OS: Darwin
OS-release: 17.3.0
machine: x86_64
processor: i386
byteorder: little
LC_ALL: None
LANG: en_US.UTF-8
LOCALE: en_US.UTF-8
pandas: 0.21.0
pytest: None
pip: 9.0.1
setuptools: 36.5.0.post20170921
Cython: None
numpy: 1.13.3
scipy: None
pyarrow: None
xarray: None
IPython: 6.2.1
sphinx: None
patsy: None
dateutil: 2.6.1
pytz: 2017.3
blosc: None
bottleneck: None
tables: None
numexpr: None
feather: None
matplotlib: 2.1.0
openpyxl: None
xlrd: None
xlwt: None
xlsxwriter: None
lxml: None
bs4: 4.6.0
html5lib: 1.0.1
sqlalchemy: None
pymysql: None
psycopg2: None
jinja2: None
s3fs: None
fastparquet: None
pandas_gbq: None
pandas_datareader: 0.5.0
The text was updated successfully, but these errors were encountered: