gpt4 book ai didi

python - ModuleNotFoundError : No module named 'pandas._libs.tslibs.frequencies'

转载 作者:行者123 更新时间:2023-12-03 23:43:17 40 4
gpt4 key购买 nike

我发现了几个关于同一问题的问题 herehere

from pyfinance.ols import PandasRollingOLS
我收到以下错误:
Traceback (most recent call last):
File "/usr/local/lib/python3.8/site-packages/pyfinance/utils.py", line 78, in <module>
from pandas.tseries.frequencies import FreqGroup, get_freq_code
ImportError: cannot import name 'FreqGroup' from 'pandas.tseries.frequencies' (/usr/local/lib/python3.8/site-packages/pandas/tseries/frequencies.py)

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "<string>", line 1, in <module>
File "/usr/local/lib/python3.8/site-packages/pyfinance/__init__.py", line 32, in <module>
from .returns import TFrame, TSeries # noqa
File "/usr/local/lib/python3.8/site-packages/pyfinance/returns.py", line 42, in <module>
from pyfinance import ols, utils
File "/usr/local/lib/python3.8/site-packages/pyfinance/ols.py", line 15, in <module>
from pyfinance import utils
File "/usr/local/lib/python3.8/site-packages/pyfinance/utils.py", line 80, in <module>
from pandas._libs.tslibs.frequencies import FreqGroup, get_freq_code
ModuleNotFoundError: No module named 'pandas._libs.tslibs.frequencies'
我尝试卸载并重新安装 Pandas 版本 1.1.3、1.1.2、1.1.1,但它们都不起作用,我只是遇到相同的错误,然后我尝试以以下方式构建 Pandas:
!python setup.py build_ext --inplace --force
我仍然得到同样的错误

最佳答案

仅供引用
我做了一些挖掘,看起来 Pandas 改变了他们的 api,这导致了提到的错误。我修改了源代码并包含在 pyfinance/utils.py 中的正确导入:
在第 77 行更改为:

try:
from pandas.tseries.frequencies import FreqGroup, get_freq_code
except ImportError: # 0.24+, or somewhere around then
from pandas._libs.tslibs.frequencies import FreqGroup, get_freq_code
try:
from pandas.tseries.frequencies import FreqGroup, get_freq_code
except ImportError:
from pandas._libs.tslibs.dtypes import FreqGroup
from pandas.tests.tslibs.test_period_asfreq import get_freq_code
我创建了一个拉取请求 here如果您遇到同样的问题,您可以克隆并安装我的 fork

关于python - ModuleNotFoundError : No module named 'pandas._libs.tslibs.frequencies' ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/64497720/

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