Knowledge Base/Canopy/Specific Canopy packages

Matplotlib -- Pandas plot gives "TypeError: an integer is required"

Jonathan March
posted this on December 11, 2013 19:46

Matplotlib 1.3.1 and Pandas 0.12 have an incompatibility which may appear when plotting from pandas. The traceback ends with:

File "..../python2.7/site-packages/pandas/core/series.py", line 981, in reshape
return ndarray.reshape(self, newshape, order)
TypeError: an integer is required
The workaround is to downgrade to matplotlib 1.3.0. (Note, however, that this version of matplotlib contains a bug on systems which have fonts with non-ASCII font names, so you may need to pick your problem!). This downgrade will trigger a downgrade to numpy 1.7.1, so you should then (again) upgrade to numpy 1.8.0.
This error should be fixed in the upcoming Pandas 0.13. However Pandas 0.13 may break some existing code (because pandas.Series is no longer a subclass of numpy.ndarray), so again, some hard choices may be required, at least in the short term.