python for Google Trends:“ValueError:year is out out of range”当使用interest_over_tim时

2024-06-09 01:54:25 发布

您现在位置:Python中文网/ 问答频道 /正文

我是python中pytrends模块的新手,它允许您从googletrends获取数据。这个网站很好地介绍了这个模块:https://github.com/GeneralMills/pytrends

使用时,我收到消息“ValueError:year is out out of range”(值错误:年份超出范围)pytrend.interest_随时间变化(). 我的代码的关键部分是:

import pytrends
from pytrends.request import TrendReq

google_username = "" #my username
google_password = "" #my password

pytrend = TrendReq(google_username, google_password, custom_useragent=None)

pytrend.build_payload(kw_list=['Chipotle'], timeframe = 'today 5-y')
pytrend.interest_over_time()

然后收到错误消息“ValueError:year is outer of range”


Tags: 模块of消息is错误googleusernamerange
2条回答

我也有同样的问题,我在请求.py在第180行

发件人:

    df['date'] = pd.to_datetime(df['time'], unit='s')

收件人:

^{pr2}$

(不知道为什么我的行号不同,但看起来是同一个问题)

在python中更改以下内容…\Lib\site packages\pytrends\请求.py在

第3行:

from datetime import datetime

围绕第128行:

^{pr2}$

这对我有用:)

相关问题 更多 >