Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

AttributeError: 'datetime.timezone' object has no attribute '_utcoffset'

I have lost ability to plot against datetime object after upgrading of matplotlib.

Error is following:

  File "/opt/anaconda3/envs/py36/lib/python3.6/site-packages/matplotlib/pyplot.py", line 2813, in plot
    is not None else {}), **kwargs)
  File "/opt/anaconda3/envs/py36/lib/python3.6/site-packages/matplotlib/__init__.py", line 1810, in inner
    return func(ax, *args, **kwargs)
  File "/opt/anaconda3/envs/py36/lib/python3.6/site-packages/matplotlib/axes/_axes.py", line 1611, in plot
    for line in self._get_lines(*args, **kwargs):
  File "/opt/anaconda3/envs/py36/lib/python3.6/site-packages/matplotlib/axes/_base.py", line 393, in _grab_next_args
    yield from self._plot_args(this, kwargs)
  File "/opt/anaconda3/envs/py36/lib/python3.6/site-packages/matplotlib/axes/_base.py", line 370, in _plot_args
    x, y = self._xy_from_xy(x, y)
  File "/opt/anaconda3/envs/py36/lib/python3.6/site-packages/matplotlib/axes/_base.py", line 204, in _xy_from_xy
    bx = self.axes.xaxis.update_units(x)
  File "/opt/anaconda3/envs/py36/lib/python3.6/site-packages/matplotlib/axis.py", line 1475, in update_units
    self.set_units(default)
  File "/opt/anaconda3/envs/py36/lib/python3.6/site-packages/matplotlib/axis.py", line 1548, in set_units
    self._update_axisinfo()
  File "/opt/anaconda3/envs/py36/lib/python3.6/site-packages/matplotlib/axis.py", line 1490, in _update_axisinfo
    info = self.converter.axisinfo(self.units, self)
  File "/opt/anaconda3/envs/py36/lib/python3.6/site-packages/pandas/plotting/_converter.py", line 353, in axisinfo
    majfmt = PandasAutoDateFormatter(majloc, tz=tz)
  File "/opt/anaconda3/envs/py36/lib/python3.6/site-packages/pandas/plotting/_converter.py", line 367, in __init__
    self._tz._utcoffset = self._tz.utcoffset(None)
AttributeError: 'datetime.timezone' object has no attribute '_utcoffset'

Is it possible to upgrade without loosing capabilities in Python?

like image 316
Dims Avatar asked Dec 25 '18 17:12

Dims


1 Answers

I think a viable workaround is indicated by this question. Basically, if you convert the pandas timestamps to str and then back to datetime, it magically works.

like image 146
Andrew Medlin Avatar answered Nov 15 '22 00:11

Andrew Medlin