pandas 0.21.0 Timestamp compatibility issue with matplotlib

There is an issue with pandas datetimes and matplotlib coming from the recent release of pandas 0.21, which does not register its converters any more at import. Once you use those converters once (within pandas) they’ll be registered and automatically used by matplotlib as well.

A workaround would be to register them manually,

import pandas.plotting._converter as pandacnv
pandacnv.register()

In any case the issue is well known at both pandas and matplotlib side, so there will be some kind of fix for the next releases. Pandas is thinking about readding the register in an upcomming release. So this issue may be there only temporarily. An option is also to revert to pandas 0.20.x where this should not occur.

Update: this is no longer an issue with current versions of matplotlib (2.2.2)/pandas(0.23.1), and likely many that have been released since roughly December 2017, when this was fixed.

Update 2: As of pandas 0.24 or higher the recommended way to register the converters is

from pandas.plotting import register_matplotlib_converters
register_matplotlib_converters()

or if pandas is already imported as pd,

pd.plotting.register_matplotlib_converters()

Leave a Comment