Skip to content

UserWarning about columns and attribute while plotting in Jupyter #18671

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

Closed
jrbrodie77 opened this issue Dec 6, 2017 · 1 comment · Fixed by #18695
Closed

UserWarning about columns and attribute while plotting in Jupyter #18671

jrbrodie77 opened this issue Dec 6, 2017 · 1 comment · Fixed by #18695

Comments

@jrbrodie77
Copy link

jrbrodie77 commented Dec 6, 2017

Code Sample, a copy-pastable example if possible

vibe_df.plot(x='Time', y='Fz')     # This works just fine.
vibe_df.plot(x='Time', y=['Fz'])     # This raises a UserWarning:

Problem description

I get a UserWarning while plotting a DataFrame. It only occurs if I pass a list of columns for y.

UserWarning is:
C:\Program Files\Anaconda3\lib\site-packages\pandas\plotting_core.py:1714: UserWarning: Pandas doesn't allow columns to be created via a new attribute name - see https://pandas.pydata.org/pandas-docs/stable/indexing.html#attribute-access
series.name = label

Expected Output

Output of pd.show_versions()

INSTALLED VERSIONS ------------------ commit: None python: 3.5.4.final.0 python-bits: 64 OS: Windows OS-release: 10 machine: AMD64 processor: Intel64 Family 6 Model 60 Stepping 3, GenuineIntel byteorder: little LC_ALL: None LANG: None LOCALE: None.None

pandas: 0.21.0
pytest: 2.9.2
pip: 9.0.1
setuptools: 27.2.0
Cython: 0.24.1
numpy: 1.11.3
scipy: 1.0.0
pyarrow: None
xarray: None
IPython: 6.2.1
sphinx: 1.4.6
patsy: 0.4.1
dateutil: 2.6.0
pytz: 2017.2
blosc: None
bottleneck: 1.1.0
tables: 3.2.2
numexpr: 2.6.4
feather: None
matplotlib: 2.1.0
openpyxl: 2.3.2
xlrd: 1.0.0
xlwt: 1.1.2
xlsxwriter: 0.9.3
lxml: 3.6.4
bs4: 4.5.1
html5lib: None
sqlalchemy: 1.0.13
pymysql: None
psycopg2: None
jinja2: 2.8
s3fs: None
fastparquet: None
pandas_gbq: None
pandas_datareader: None

@TomAugspurger
Copy link
Contributor

This is the line

series.name = label

That code pretty clearly assumes that 'y' is a scalar, and that's how it's documented

Parameters
----------
data : DataFrame
x : label or position, default None
y : label or position, default None
    Allows plotting of one column versus another

So we can either validate that data[y] is a Series, and raise if not, or see if we can support and document multiple values for 'y'.

btw, here's a reproducible example

In [12]: df = pd.DataFrame({"A": [1, 2], 'B': [3, 4], 'C': [5, 6]})

In [13]: df.plot(x='A', y=['B', 'C'])

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.

4 participants