Skip to content

dataframe plot method throws an error #19340

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
shantanuo opened this issue Jan 22, 2018 · 13 comments
Closed

dataframe plot method throws an error #19340

shantanuo opened this issue Jan 22, 2018 · 13 comments

Comments

@shantanuo
Copy link

Code Sample, a copy-pastable example if possible

import pandas as pd
import numpy as np
import matplotlib
import matplotlib.pyplot as plt

ts = pd.Series(np.random.randn(1000), index=pd.date_range('1/1/2000', periods=1000))
ts = ts.cumsum()
ts.plot()

Problem description

Getting an error:

NameError: name '_converter' is not defined

https://stackoverflow.com/questions/48341233/ts-plot-and-dataframe-plot-throwing-error-nameerror-name-converter-is

Expected Output

chart as usual

Output of pd.show_versions()

INSTALLED VERSIONS

commit: None
python: 3.6.2.final.0
python-bits: 64
OS: Linux
OS-release: 4.9.75-25.55.amzn1.x86_64
machine: x86_64
processor:
byteorder: little
LC_ALL: C.UTF-8
LANG: C.UTF-8
LOCALE: en_US.UTF-8

pandas: 0.22.0
pytest: 3.3.2
pip: 9.0.1
setuptools: 36.5.0.post20170921
Cython: 0.27.3
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.2
openpyxl: 2.4.9
xlrd: None
xlwt: None
xlsxwriter: None
lxml: 4.1.1
bs4: 4.6.0
html5lib: 1.0.1
sqlalchemy: 1.2.1
pymysql: 0.8.0
psycopg2: None
jinja2: 2.10
s3fs: None
fastparquet: 0.1.3
pandas_gbq: None
pandas_datareader: None

@shantanuo
Copy link
Author

---------------------------------------------------------------------------
NameError                                 Traceback (most recent call last)
<ipython-input-61-c6f8bd02937c> in <module>()
      7 ts = ts.cumsum()
      8 
----> 9 ts.asfreq('D').plot();
     10 plt.show()

/opt/conda/lib/python3.6/site-packages/pandas/plotting/_core.py in __call__(self, kind, ax, figsize, use_index, title, grid, legend, style, logx, logy, loglog, xticks, yticks, xlim, ylim, rot, fontsize, colormap, table, yerr, xerr, label, secondary_y, **kwds)
   2501                            colormap=colormap, table=table, yerr=yerr,
   2502                            xerr=xerr, label=label, secondary_y=secondary_y,
-> 2503                            **kwds)
   2504     __call__.__doc__ = plot_series.__doc__
   2505 

/opt/conda/lib/python3.6/site-packages/pandas/plotting/_core.py in plot_series(data, kind, ax, figsize, use_index, title, grid, legend, style, logx, logy, loglog, xticks, yticks, xlim, ylim, rot, fontsize, colormap, table, yerr, xerr, label, secondary_y, **kwds)
   1925                  yerr=yerr, xerr=xerr,
   1926                  label=label, secondary_y=secondary_y,
-> 1927                  **kwds)
   1928 
   1929 

/opt/conda/lib/python3.6/site-packages/pandas/plotting/_core.py in _plot(data, x, y, subplots, ax, kind, **kwds)
   1725                             pass
   1726                 data = series
-> 1727         plot_obj = klass(data, subplots=subplots, ax=ax, kind=kind, **kwds)
   1728 
   1729     plot_obj.generate()

/opt/conda/lib/python3.6/site-packages/pandas/plotting/_core.py in __init__(self, data, **kwargs)
    929 
    930     def __init__(self, data, **kwargs):
--> 931         MPLPlot.__init__(self, data, **kwargs)
    932         if self.stacked:
    933             self.data = self.data.fillna(value=0)

/opt/conda/lib/python3.6/site-packages/pandas/plotting/_core.py in __init__(self, data, kind, by, subplots, sharex, sharey, use_index, figsize, grid, legend, rot, ax, fig, title, xlim, ylim, xticks, yticks, sort_columns, fontsize, secondary_y, colormap, table, layout, **kwds)
     98                  table=False, layout=None, **kwds):
     99 
--> 100         _converter._WARN = False
    101         self.data = data
    102         self.by = by

NameError: name '_converter' is not defined


@TomAugspurger
Copy link
Contributor

Try this:

from pandas.plotting._misc import (scatter_matrix, radviz,
                                   andrews_curves, bootstrap_plot,
                                   parallel_coordinates, lag_plot,
                                   autocorrelation_plot)
from pandas.plotting._core import boxplot
from pandas.plotting._style import plot_params
from pandas.plotting._tools import table

from pandas.plotting._converter import \
    register as register_matplotlib_converters
from pandas.plotting._converter import \
    deregister as deregister_matplotlib_converters

and let me know if any of those imports fail.

@shantanuo
Copy link
Author

None of the imports fail. And still getting the same error as mentioned above.

@TomAugspurger
Copy link
Contributor

Can you reproduce this in a fresh environment?

@shantanuo
Copy link
Author

After restarting server (docker container in my case) plot method worked as expected.

@bjourne
Copy link

bjourne commented Feb 9, 2018

I had the same error, but after installing matplotlib and scipy it solved itself. I guess those deps should be checked in a nicer way?

@jreback jreback added the Visualization plotting label Feb 10, 2018
@jreback
Copy link
Contributor

jreback commented Feb 10, 2018

@bjourne so you you ran the above code (top of PR) and it didn't raise on the import matplotlib when it was not installed?

@jreback jreback added this to the No action milestone Feb 10, 2018
@bjourne
Copy link

bjourne commented Feb 10, 2018

I never ran the same code, but I had the same error. In my case, it was triggered by an call to df.plot.kde() where df was a pandas.DataFrame.

@ikari-pl
Copy link

ikari-pl commented Feb 11, 2018

I ran into the same error, thrown at dataframe.hist(), installing scipy and matplotlib didn't seem to do the trick (or I did it wrong?)

@jorisvandenbossche
Copy link
Member

@ikari-pl Can you run the code in the top post? Do you then also get this error?

@peacing
Copy link

peacing commented Feb 15, 2018

I had the same error as above. After installing scipy AND restarting jupyter notebook plotting worked for me. I think restarting the notebook has to happen.

@TomAugspurger
Copy link
Contributor

TomAugspurger commented Feb 15, 2018 via email

@HarzeetSingh
Copy link

UNINSTALL PANDAS
UNINSTALL MATPLOTLIB
INSTALL PANDAS
INSTALL MATPLOTLIB
RESTART JUPYTER

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

No branches or pull requests

8 participants