gpt4 book ai didi

python - 属性错误 : 'datetime.timezone' object has no attribute '_utcoffset'

转载 作者:行者123 更新时间:2023-11-28 18:05:12 31 4
gpt4 key购买 nike

升级 matplotlib 后,我失去了绘制日期时间对象的能力。

错误如下:

  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'

是否可以在不丢失 Python 功能的情况下进行升级?

最佳答案

我认为可行的解决方法由 this question 指示.基本上,如果您将 pandas 时间戳转换为 str,然后再转换回 datetime,它会神奇地起作用。

关于python - 属性错误 : 'datetime.timezone' object has no attribute '_utcoffset' ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/53924387/

31 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com