Last active
July 28, 2020 13:26
-
-
Save NehaAkashDeo/17701f22af17d705d8c23db335687673 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| ipywidgets | |
| pandas | |
| pytrends |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| { | |
| "cells": [ | |
| { | |
| "cell_type": "code", | |
| "execution_count": 30, | |
| "metadata": { | |
| "collapsed": true | |
| }, | |
| "outputs": [], | |
| "source": [ | |
| "import pytrends\n", | |
| "from ipywidgets import interact\n", | |
| "from pytrends.request import TrendReq\n", | |
| "pytrend = TrendReq()\n", | |
| "import pandas as pd" | |
| ] | |
| }, | |
| { | |
| "cell_type": "code", | |
| "execution_count": 27, | |
| "metadata": { | |
| "collapsed": true | |
| }, | |
| "outputs": [ | |
| { | |
| "name": "stdout", | |
| "output_type": "stream", | |
| "text": [ | |
| "Please enter keywords to be searched (Separated by Commas)\n", | |
| "\n" | |
| ] | |
| }, | |
| { | |
| "data": { | |
| "application/vnd.jupyter.widget-view+json": { | |
| "model_id": "3b23cae3b4cf431cbd0250d66c7bec41", | |
| "version_major": 2, | |
| "version_minor": 0 | |
| }, | |
| "text/plain": [ | |
| "interactive(children=(Text(value='India,America', description='kw1'), Output()), _dom_classes=('widget-interac…" | |
| ] | |
| }, | |
| "metadata": {}, | |
| "output_type": "display_data" | |
| } | |
| ], | |
| "source": [ | |
| "kw_list=[]\n", | |
| "\n", | |
| "def display(kw1):\n", | |
| " global kw_list\n", | |
| " kw_list=kw1.split(\",\")\n", | |
| " return kw1\n", | |
| "\n", | |
| "print(\"Please enter keywords to be searched (Separated by Commas)\\n\")\n", | |
| "kw_list=interact(display, kw1=\"India,America\");" | |
| ] | |
| }, | |
| { | |
| "cell_type": "code", | |
| "execution_count": 31, | |
| "metadata": { | |
| "collapsed": true | |
| }, | |
| "outputs": [], | |
| "source": [ | |
| "pytrend.build_payload(kw_list=kw_list, timeframe='today 5-y', geo='IN')" | |
| ] | |
| }, | |
| { | |
| "cell_type": "code", | |
| "execution_count": 32, | |
| "metadata": { | |
| "collapsed": true | |
| }, | |
| "outputs": [ | |
| { | |
| "name": "stdout", | |
| "output_type": "stream", | |
| "text": [ | |
| " Plants Animals isPartial\n", | |
| "date \n", | |
| "2015-08-02 36 76 False\n", | |
| "2015-08-09 35 77 False\n", | |
| "2015-08-16 38 78 False\n", | |
| "2015-08-23 32 75 False\n", | |
| "2015-08-30 34 71 False\n", | |
| "... ... ... ...\n", | |
| "2020-06-21 64 66 False\n", | |
| "2020-06-28 68 70 False\n", | |
| "2020-07-05 67 66 False\n", | |
| "2020-07-12 71 67 False\n", | |
| "2020-07-19 72 68 False\n", | |
| "\n", | |
| "[260 rows x 3 columns]\n" | |
| ] | |
| } | |
| ], | |
| "source": [ | |
| "interest_over_time_df=pytrend.interest_over_time()\n", | |
| "print(interest_over_time_df)" | |
| ] | |
| }, | |
| { | |
| "cell_type": "code", | |
| "execution_count": null, | |
| "metadata": {}, | |
| "outputs": [], | |
| "source": [] | |
| } | |
| ], | |
| "metadata": { | |
| "kernelspec": { | |
| "display_name": "Python 3", | |
| "language": "python", | |
| "name": "python3" | |
| }, | |
| "language_info": { | |
| "codemirror_mode": { | |
| "name": "ipython", | |
| "version": 3 | |
| }, | |
| "file_extension": ".py", | |
| "mimetype": "text/x-python", | |
| "name": "python", | |
| "nbconvert_exporter": "python", | |
| "pygments_lexer": "ipython3", | |
| "version": "3.7.6" | |
| } | |
| }, | |
| "nbformat": 4, | |
| "nbformat_minor": 2 | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment