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

plotting dtype "UInt32" fails #25587

Closed
teto opened this issue Mar 7, 2019 · 4 comments · Fixed by #25590
Closed

plotting dtype "UInt32" fails #25587

teto opened this issue Mar 7, 2019 · 4 comments · Fixed by #25590
Labels
ExtensionArray Extending pandas with custom dtypes or arrays. Visualization plotting
Milestone

Comments

@teto
Copy link

teto commented Mar 7, 2019

Code Sample, a copy-pastable example if possible

import pandas as pd

s = pd.Series([ 4, 5, 3 ,2 ], dtype="UInt32")
s.astype("int32").plot() # succeeds
s.plot() # fails

fails with

Traceback (most recent call last):
  File "test_plot.py", line 7, in <module>
    s.plot()
  File "/nix/store/biq309lxqwpl1nfap4h3s58wcxd134xq-python3.7-pandas-0.24.1/lib/python3.7/site-packages/pandas/plotting/_core.py", line 2740, in __call__
    **kwds)
  File "/nix/store/biq309lxqwpl1nfap4h3s58wcxd134xq-python3.7-pandas-0.24.1/lib/python3.7/site-packages/pandas/plotting/_core.py", line 1995, in plot_series
    **kwds)
  File "/nix/store/biq309lxqwpl1nfap4h3s58wcxd134xq-python3.7-pandas-0.24.1/lib/python3.7/site-packages/pandas/plotting/_core.py", line 1798, in _plot
    plot_obj.generate()
  File "/nix/store/biq309lxqwpl1nfap4h3s58wcxd134xq-python3.7-pandas-0.24.1/lib/python3.7/site-packages/pandas/plotting/_core.py", line 251, in generate
    self._make_plot()
  File "/nix/store/biq309lxqwpl1nfap4h3s58wcxd134xq-python3.7-pandas-0.24.1/lib/python3.7/site-packages/pandas/plotting/_core.py", line 993, in _make_plot
    **kwds)
  File "/nix/store/biq309lxqwpl1nfap4h3s58wcxd134xq-python3.7-pandas-0.24.1/lib/python3.7/site-packages/pandas/plotting/_core.py", line 1008, in _plot
    lines = MPLPlot._plot(ax, x, y_values, style=style, **kwds)
  File "/nix/store/biq309lxqwpl1nfap4h3s58wcxd134xq-python3.7-pandas-0.24.1/lib/python3.7/site-packages/pandas/plotting/_core.py", line 598, in _plot
    return ax.plot(*args, **kwds)
  File "/nix/store/xgfsbxa29szyi30hl48hac1gihic3z3f-python3.7-matplotlib-3.0.3/lib/python3.7/site-packages/matplotlib/__init__.py", line 1810, in inner
    return func(ax, *args, **kwargs)
  File "/nix/store/xgfsbxa29szyi30hl48hac1gihic3z3f-python3.7-matplotlib-3.0.3/lib/python3.7/site-packages/matplotlib/axes/_axes.py", line 1611, in plot
    for line in self._get_lines(*args, **kwargs):
  File "/nix/store/xgfsbxa29szyi30hl48hac1gihic3z3f-python3.7-matplotlib-3.0.3/lib/python3.7/site-packages/matplotlib/axes/_base.py", line 393, in _grab_next_args
    yield from self._plot_args(this, kwargs)
  File "/nix/store/xgfsbxa29szyi30hl48hac1gihic3z3f-python3.7-matplotlib-3.0.3/lib/python3.7/site-packages/matplotlib/axes/_base.py", line 378, in _plot_args
    ncx, ncy = x.shape[1], y.shape[1]
IndexError: tuple index out of range

Problem description

When using the new type UInt32, plotting won't work.

Output of pd.show_versions()

[paste the output of pd.show_versions() here below this line]
INSTALLED VERSIONS

commit: None
python: 3.7.2.final.0
python-bits: 64
OS: Linux
OS-release: 4.20.12
machine: x86_64
processor:
byteorder: little
LC_ALL: None
LANG: C.UTF-8
LOCALE: None.None

pandas: 0+unknown
pytest: None
pip: 19.0.3
setuptools: 40.8.0
Cython: None
numpy: 1.16.1
scipy: 1.2.1
pyarrow: None
xarray: None
IPython: None
sphinx: None
patsy: None
dateutil: 2.8.0
pytz: 2018.9
blosc: None
bottleneck: 1.2.1
tables: 3.4.4
numexpr: 2.6.9
feather: None
matplotlib: 3.0.3
openpyxl: 2.6.0
xlrd: 1.2.0
xlwt: 1.3.0
xlsxwriter: None
lxml.etree: 4.3.1
bs4: 4.7.1
html5lib: 1.0.1
sqlalchemy: 1.2.14
pymysql: None
psycopg2: None
jinja2: None
s3fs: None
fastparquet: None
pandas_gbq: None
pandas_datareader: None
gcsfs: None

@tikael1011
Copy link

pandas: 0+unknown, why is this?

@teto
Copy link
Author

teto commented Mar 7, 2019

it's pandas 0.24.1 with this commit applied on top #25289. I haven't tried master but the bug should be valid for 0.24.1.

@TomAugspurger TomAugspurger added Visualization plotting ExtensionArray Extending pandas with custom dtypes or arrays. labels Mar 7, 2019
@TomAugspurger TomAugspurger added this to the Contributions Welcome milestone Mar 7, 2019
@TomAugspurger
Copy link
Contributor

Thanks for the report. Let us know if you want to work on a fix for this. Something in matplotlib doesn't like extension arrays, which can't be reshaped to 2d arrays. We may need to convert before passing to mpl.

@jreback jreback modified the milestones: Contributions Welcome, 0.25.0 Mar 13, 2019
@teto
Copy link
Author

teto commented Mar 18, 2019

thanks for the prompt fix !

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
ExtensionArray Extending pandas with custom dtypes or arrays. Visualization plotting
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants