Profile picture

Co-founder @ RMOTR

PyTrends Test

Last updated: June 5th, 20192019-06-05Project preview
In [1]:
!pip install pytrends
Collecting pytrends
  Downloading https://files.pythonhosted.org/packages/c7/ca/bf9ed973416290270c9aea8f8b3cf7e75a2280918838a4bea4067019ef11/pytrends-4.6.0-py3-none-any.whl
Requirement already satisfied: pandas in /usr/local/lib/python3.6/site-packages (from pytrends) (0.23.0)
Requirement already satisfied: lxml in /usr/local/lib/python3.6/site-packages (from pytrends) (4.3.0)
Requirement already satisfied: requests in /usr/local/lib/python3.6/site-packages (from pytrends) (2.21.0)
Requirement already satisfied: pytz>=2011k in /usr/local/lib/python3.6/site-packages (from pandas->pytrends) (2018.9)
Requirement already satisfied: python-dateutil>=2.5.0 in /usr/local/lib/python3.6/site-packages (from pandas->pytrends) (2.7.5)
Requirement already satisfied: numpy>=1.9.0 in /usr/local/lib/python3.6/site-packages (from pandas->pytrends) (1.14.5)
Requirement already satisfied: urllib3<1.25,>=1.21.1 in /usr/local/lib/python3.6/site-packages (from requests->pytrends) (1.24.1)
Requirement already satisfied: certifi>=2017.4.17 in /usr/local/lib/python3.6/site-packages (from requests->pytrends) (2018.11.29)
Requirement already satisfied: chardet<3.1.0,>=3.0.2 in /usr/local/lib/python3.6/site-packages (from requests->pytrends) (3.0.4)
Requirement already satisfied: idna<2.9,>=2.5 in /usr/local/lib/python3.6/site-packages (from requests->pytrends) (2.8)
Requirement already satisfied: six>=1.5 in /usr/local/lib/python3.6/site-packages (from python-dateutil>=2.5.0->pandas->pytrends) (1.12.0)
Installing collected packages: pytrends
Successfully installed pytrends-4.6.0
You are using pip version 19.0.1, however version 19.1.1 is available.
You should consider upgrading via the 'pip install --upgrade pip' command.
In [2]:
from pytrends.request import TrendReq
In [3]:
pytrends = TrendReq(hl='en-US', tz=360)
In [5]:
kw_list = ["Blockchain"]
In [6]:
pytrends.build_payload(kw_list, cat=0, timeframe='today 5-y', geo='', gprop='')
In [10]:
pytrends.interest_over_time().head()
Out[10]:
Blockchain isPartial
date
2019-01-29 00:00:00 55 False
2019-01-29 01:00:00 60 False
2019-01-29 02:00:00 65 False
2019-01-29 03:00:00 75 False
2019-01-29 04:00:00 84 False
In [9]:
pytrends.get_historical_interest(
    kw_list, year_start=2019, month_start=1, day_start=1, hour_start=0,
    year_end=2019, month_end=2, day_end=1, hour_end=0,
    cat=0, geo='', gprop='', sleep=0).head()
Out[9]:
Blockchain isPartial
date
2019-01-01 00:00:00 0 False
2019-01-01 01:00:00 0 False
2019-01-01 02:00:00 0 False
2019-01-01 03:00:00 0 False
2019-01-01 04:00:00 0 False
In [ ]:
 
Notebooks AI
Notebooks AI Profile20060