Created
July 22, 2020 11:04
-
-
Save NehaAkashDeo/3bf39f4e3ac3a8bc63e8f0e110cc8afc 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
| { | |
| "cells": [ | |
| { | |
| "cell_type": "code", | |
| "execution_count": null, | |
| "metadata": {}, | |
| "outputs": [], | |
| "source": [ | |
| "import pytrends\n", | |
| "import pandas as pd \n", | |
| "from pytrends.request import TrendReq\n", | |
| "pytrend = TrendReq()" | |
| ] | |
| }, | |
| { | |
| "cell_type": "code", | |
| "execution_count": null, | |
| "metadata": {}, | |
| "outputs": [], | |
| "source": [ | |
| "a = input(\"Compare Search Trends (Provide keywords seperated by commas):\")\n", | |
| "kw_list=a.split(',')\n", | |
| "print(kw_list)" | |
| ] | |
| }, | |
| { | |
| "cell_type": "code", | |
| "execution_count": null, | |
| "metadata": {}, | |
| "outputs": [], | |
| "source": [ | |
| "pytrend.build_payload(kw_list=kw_list, timeframe='today 5-y', geo='IN')" | |
| ] | |
| }, | |
| { | |
| "cell_type": "code", | |
| "execution_count": null, | |
| "metadata": {}, | |
| "outputs": [], | |
| "source": [ | |
| "interest_over_time_df=pytrend.interest_over_time()\n", | |
| "print(interest_over_time_df)" | |
| ] | |
| }, | |
| { | |
| "cell_type": "code", | |
| "execution_count": null, | |
| "metadata": {}, | |
| "outputs": [], | |
| "source": [ | |
| "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": [ | |
| "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()" | |
| ] | |
| }, | |
| { | |
| "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