Last active
July 24, 2020 18:55
-
-
Save NehaAkashDeo/524efcf115adb56d9c62fe7c5fe84db1 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
| ipython | |
| pytrends | |
| ipywidgets | |
| matplotlib | |
| pandas |
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": null, | |
| "metadata": {}, | |
| "outputs": [], | |
| "source": [ | |
| "# nbi:hide_in \n", | |
| "\n", | |
| "import pytrends\n", | |
| "import pandas as pd \n", | |
| "from pytrends.request import TrendReq\n", | |
| "from ipywidgets import widgets\n", | |
| "from IPython.display import display\n", | |
| "pytrend = TrendReq()\n", | |
| "\n", | |
| "from matplotlib import pyplot as plt \n", | |
| "import time\n", | |
| "import datetime\n", | |
| "from datetime import datetime, date, time\n", | |
| "\n", | |
| "# %matplotlib inline" | |
| ] | |
| }, | |
| { | |
| "cell_type": "code", | |
| "execution_count": null, | |
| "metadata": {}, | |
| "outputs": [], | |
| "source": [ | |
| "# nbi:hide_in\n", | |
| "\n", | |
| "kw_list=[]\n", | |
| "\n", | |
| "def add_list(b):\n", | |
| " kw1=txt1.value\n", | |
| " kw2=txt2.value\n", | |
| " kw_list.extend([kw1, kw2])\n", | |
| " print(f\"Compare Search Trends:: {kw_list}\")\n", | |
| " pytrend.build_payload(kw_list=kw_list, timeframe='today 5-y', geo='IN')\n", | |
| " interest_over_time_df=pytrend.interest_over_time()\n", | |
| " print(interest_over_time_df)\n", | |
| " dx= interest_over_time_df.plot.line(figsize=(12,8), title=\"Interest over time\",colormap=\"Set1\", linewidth=3)\n", | |
| " dx.set_xlabel(\"Date\", fontsize=22)\n", | |
| " dx.set_ylabel(\"Interest Over Time\", fontsize=22)\n", | |
| " dx.tick_params(axis='both', which='major', labelsize=22)\n", | |
| " dx.set_title('Comparison Across Keywords',fontsize=30)\n", | |
| " dx.legend(fontsize=15)\n", | |
| "\n", | |
| " dx.text(2640,-2,'Machine Generated Insights', style='italic', bbox={'facecolor': 'grey', 'alpha': 0.5, 'pad': 3}, rotation=270)\n", | |
| " plt.show()\n", | |
| "\n", | |
| "keywords1=widgets.Label(\"Enter Keywords 1 : \")\n", | |
| "display(keywords1)\n", | |
| "txt1=widgets.Text()\n", | |
| "display(txt1)\n", | |
| "\n", | |
| "keywords2=widgets.Label(\"Enter Keywords 2 : \")\n", | |
| "display(keywords2)\n", | |
| "txt2=widgets.Text()\n", | |
| "display(txt2)\n", | |
| "\n", | |
| "btn=widgets.Button(description=\"Submit\")\n", | |
| "display(btn)\n", | |
| "btn.on_click(add_list)" | |
| ] | |
| }, | |
| { | |
| "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