【发布时间】:2018-04-09 12:09:37
【问题描述】:
我正在使用 pytrends python 包来拉搜索词的流行度。看起来默认频率是每周,但我需要每日数据。有没有可以调整的参数?我似乎找不到任何东西。这里有一些代码可以让你到达同一个地方...
import pytrends
import matplotlib.pyplot as plt
%matplotlib inline
from pytrends.request import TrendReq
pytrends = TrendReq(hl='en-US', tz=360)
pytrends.build_payload(["sp500", "dogs"], cat=0, timeframe='today 5-y', geo='', gprop='')
df = pytrends.interest_over_time()
df.tail()
如您所见,返回的数据帧每周采样一次。我如何才能获得 5 年前但每天的相同数据?
【问题讨论】:
-
google 趋势不提供超过 90 天的时间间隔的这种粒度的数据,但可以请求重叠间隔然后调整它们。我在 R github.com/321k/Google-Trends/blob/master/… 中找到了这个例子
-
如果我的回答回答了你的问题,你能接受吗?这是社区的普遍做法。
标签: python pandas google-trends