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()
Comment From: shantanuo
---------------------------------------------------------------------------
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
Comment From: TomAugspurger
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.
Comment From: shantanuo
None of the imports fail. And still getting the same error as mentioned above.
Comment From: TomAugspurger
Can you reproduce this in a fresh environment?
Comment From: shantanuo
After restarting server (docker container in my case) plot method worked as expected.
Comment From: bjourne
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?
Comment From: jreback
@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?
Comment From: bjourne
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
.
Comment From: ikari-pl
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?)
Comment From: jorisvandenbossche
@ikari-pl Can you run the code in the top post? Do you then also get this error?
Comment From: peacing
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.
Comment From: TomAugspurger
That's true in general. Python doesn't handle dynamically reloading modules well.
On Thu, Feb 15, 2018 at 12:14 PM, Paul Singman notifications@github.com wrote:
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.
— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/pandas-dev/pandas/issues/19340#issuecomment-366014345, or mute the thread https://github.com/notifications/unsubscribe-auth/ABQHIp1EOvHyXNxYk7vVfl7mM-aJh_Owks5tVHQKgaJpZM4RmPJr .
Comment From: HarzeetSingh
UNINSTALL PANDAS UNINSTALL MATPLOTLIB INSTALL PANDAS INSTALL MATPLOTLIB RESTART JUPYTER