pytrends(谷歌趋势)每日频率 [英] pytrends (Google Trends) daily freq

查看:146
本文介绍了pytrends(谷歌趋势)每日频率的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用 pytrends python 包来拉取搜索词的流行度.看起来默认频率是每周,但我需要每日数据.有没有可以调整的参数?我似乎找不到任何东西.这里有一些代码可以让你到达同一个地方......

导入pytrends导入 matplotlib.pyplot 作为 plt%matplotlib 内联从 pytrends.request 导入 TrendReqpytrends = 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 年前但每天的相同数据?

解决方案

我正在访问这个问题,因为我正在搜索这个主题.截至今天(2019 年),pytrends 库有一个方法可以返回关键字的每日数据.

我建议查看他们的 github 存储库.>

我应该指出,我没有测试我们可以在多大程度上获得数据,但我确信文档中的某个地方有这个信息.

示例:

from pytrends.request import TrendReq从 pytrends 导入每日数据df = dailydata.get_daily_data('cinema', 2019, 1, 2019, 10, geo = 'BR')打印(df)

输出

 Cinema_unscaled Cinema_monthly isPartial scale Cinema日期2019-01-01 60 NaN NaN NaN NaN2019-01-02 76 NaN NaN NaN NaN2019-01-03 82 NaN NaN NaN NaN2019-01-04 71 NaN NaN NaN NaN2019-01-05 100 NaN NaN NaN NaN………………2019-10-26 74 38.0 NaN 0.38 28.122019-10-27 74 33.0 真 0.33 24.422019-10-28 53 33.0 NaN 0.33 17.492019-10-29 37 33.0 NaN 0.33 12.212019-10-30 34 33.0 NaN 0.33 11.22

I am using the pytrends python package to pull search term popularity. It looks like the default frequency is weekly but I need daily data. Is there a parameter to adjust for that? I can't seem to find anything. Here is some code to get you to the same place...

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()

as you can see, the dataframe returned is sampled weekly. How can I get the same data going back 5 yrs, but daily?

解决方案

I'm visiting this question because i was searching this topic. As of today (2019), the pytrends library has a method that returns daily data for a keyword.

I recommend checking their github repository.

I should point out that i didn't test it how far we can get data, but i'm sure that somewhere in the documentation has this information.

Example:

from pytrends.request import TrendReq
from pytrends import dailydata

df = dailydata.get_daily_data('cinema', 2019, 1, 2019, 10, geo = 'BR')

print(df)

Output

            cinema_unscaled  cinema_monthly isPartial  scale  cinema
date                                                                
2019-01-01               60             NaN       NaN    NaN     NaN
2019-01-02               76             NaN       NaN    NaN     NaN
2019-01-03               82             NaN       NaN    NaN     NaN
2019-01-04               71             NaN       NaN    NaN     NaN
2019-01-05              100             NaN       NaN    NaN     NaN
                    ...             ...       ...    ...     ...
2019-10-26               74            38.0       NaN   0.38   28.12
2019-10-27               74            33.0      True   0.33   24.42
2019-10-28               53            33.0       NaN   0.33   17.49
2019-10-29               37            33.0       NaN   0.33   12.21
2019-10-30               34            33.0       NaN   0.33   11.22

这篇关于pytrends(谷歌趋势)每日频率的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆