5

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?

Merv Merzoug
  • 1,149
  • 2
  • 19
  • 33
  • google trends doesn't provide data at such granularity for time intervals longer than 90 days, but it is possible to request overlapping intervals and then adjust them. I found this example in R https://github.com/321k/Google-Trends/blob/master/Daily%20data%20example.R – groceryheist Jan 18 '19 at 23:19
  • IIf my response answered your question, could you accept the answer? It's the common practice in the community. – MrCorote Jan 02 '22 at 22:45

1 Answers1

9

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

MrCorote
  • 565
  • 8
  • 21