Created
November 17, 2021 14:44
-
-
Save codewithpom/b0d4df4e1c7b6058ea784fec27af3065 to your computer and use it in GitHub Desktop.
A jupyter notebook with Google Trend analysis on a topic plotted with plotly.
This file contains 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": "markdown", | |
"metadata": {}, | |
"source": [ | |
"# Test it\n", | |
"[datalore](https://datalore.jetbrains.com/notebook/XKSXNL66DlEB7PwmhUEWRy/0910N4XZh2E9gLjQUNrVAV/)\n" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": null, | |
"metadata": {}, | |
"outputs": [], | |
"source": [ | |
"# Install the Modules\n", | |
"!pip install pytrends\n", | |
"!pip install plotly\n" | |
] | |
}, | |
{ | |
"cell_type": "markdown", | |
"metadata": {}, | |
"source": [ | |
"# Create Object\n", | |
"Create Object and import libraries" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": 4, | |
"metadata": {}, | |
"outputs": [], | |
"source": [ | |
"from pytrends.request import TrendReq # For Trend analysis\n", | |
"import plotly.express as px # For ploting it\n", | |
"\n", | |
"pytrends = TrendReq(hl='en-US', tz=360) # Initialize the trend object" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": 5, | |
"metadata": {}, | |
"outputs": [], | |
"source": [ | |
"# build payload\n", | |
"\n", | |
"kw_list = [\"machine learning\"] # list of keywords to get data \n", | |
"\n", | |
"pytrends.build_payload(kw_list, cat=0, timeframe='today 12-m') # create payload" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": 8, | |
"metadata": {}, | |
"outputs": [ | |
{ | |
"data": { | |
"application/vnd.plotly.v1+json": { | |
"config": { | |
"plotlyServerURL": "https://plot.ly" | |
}, | |
"data": [ | |
{ | |
"hovertemplate": "variable=machine learning<br>date=%{x}<br>value=%{y}<extra></extra>", | |
"legendgroup": "machine learning", | |
"line": { | |
"color": "#636efa", | |
"dash": "solid" | |
}, | |
"marker": { | |
"symbol": "circle" | |
}, | |
"mode": "lines", | |
"name": "machine learning", | |
"orientation": "v", | |
"showlegend": true, | |
"type": "scatter", | |
"x": [ | |
"2020-11-08T00:00:00", | |
"2020-11-15T00:00:00", | |
"2020-11-22T00:00:00", | |
"2020-11-29T00:00:00", | |
"2020-12-06T00:00:00", | |
"2020-12-13T00:00:00", | |
"2020-12-20T00:00:00", | |
"2020-12-27T00:00:00", | |
"2021-01-03T00:00:00", | |
"2021-01-10T00:00:00", | |
"2021-01-17T00:00:00", | |
"2021-01-24T00:00:00", | |
"2021-01-31T00:00:00", | |
"2021-02-07T00:00:00", | |
"2021-02-14T00:00:00", | |
"2021-02-21T00:00:00", | |
"2021-02-28T00:00:00", | |
"2021-03-07T00:00:00", | |
"2021-03-14T00:00:00", | |
"2021-03-21T00:00:00", | |
"2021-03-28T00:00:00", | |
"2021-04-04T00:00:00", | |
"2021-04-11T00:00:00", | |
"2021-04-18T00:00:00", | |
"2021-04-25T00:00:00", | |
"2021-05-02T00:00:00", | |
"2021-05-09T00:00:00", | |
"2021-05-16T00:00:00", | |
"2021-05-23T00:00:00", | |
"2021-05-30T00:00:00", | |
"2021-06-06T00:00:00", | |
"2021-06-13T00:00:00", | |
"2021-06-20T00:00:00", | |
"2021-06-27T00:00:00", | |
"2021-07-04T00:00:00", | |
"2021-07-11T00:00:00", | |
"2021-07-18T00:00:00", | |
"2021-07-25T00:00:00", | |
"2021-08-01T00:00:00", | |
"2021-08-08T00:00:00", | |
"2021-08-15T00:00:00", | |
"2021-08-22T00:00:00", | |
"2021-08-29T00:00:00", | |
"2021-09-05T00:00:00", | |
"2021-09-12T00:00:00", | |
"2021-09-19T00:00:00", | |
"2021-09-26T00:00:00", | |
"2021-10-03T00:00:00", | |
"2021-10-10T00:00:00", | |
"2021-10-17T00:00:00", | |
"2021-10-24T00:00:00", | |
"2021-10-31T00:00:00" | |
], | |
"xaxis": "x", | |
"y": [ | |
84, | |
89, | |
81, | |
89, | |
95, | |
83, | |
73, | |
73, | |
80, | |
85, | |
89, | |
87, | |
91, | |
83, | |
86, | |
89, | |
93, | |
90, | |
94, | |
89, | |
84, | |
87, | |
85, | |
96, | |
87, | |
87, | |
82, | |
88, | |
92, | |
91, | |
81, | |
92, | |
94, | |
90, | |
85, | |
92, | |
91, | |
89, | |
81, | |
89, | |
82, | |
87, | |
82, | |
84, | |
92, | |
91, | |
100, | |
100, | |
90, | |
87, | |
99, | |
89 | |
], | |
"yaxis": "y" | |
} | |
], | |
"layout": { | |
"legend": { | |
"title": { | |
"text": "variable" | |
}, | |
"tracegroupgap": 0 | |
}, | |
"template": { | |
"data": { | |
"bar": [ | |
{ | |
"error_x": { | |
"color": "#2a3f5f" | |
}, | |
"error_y": { | |
"color": "#2a3f5f" | |
}, | |
"marker": { | |
"line": { | |
"color": "#E5ECF6", | |
"width": 0.5 | |
}, | |
"pattern": { | |
"fillmode": "overlay", | |
"size": 10, | |
"solidity": 0.2 | |
} | |
}, | |
"type": "bar" | |
} | |
], | |
"barpolar": [ | |
{ | |
"marker": { | |
"line": { | |
"color": "#E5ECF6", | |
"width": 0.5 | |
}, | |
"pattern": { | |
"fillmode": "overlay", | |
"size": 10, | |
"solidity": 0.2 | |
} | |
}, | |
"type": "barpolar" | |
} | |
], | |
"carpet": [ | |
{ | |
"aaxis": { | |
"endlinecolor": "#2a3f5f", | |
"gridcolor": "white", | |
"linecolor": "white", | |
"minorgridcolor": "white", | |
"startlinecolor": "#2a3f5f" | |
}, | |
"baxis": { | |
"endlinecolor": "#2a3f5f", | |
"gridcolor": "white", | |
"linecolor": "white", | |
"minorgridcolor": "white", | |
"startlinecolor": "#2a3f5f" | |
}, | |
"type": "carpet" | |
} | |
], | |
"choropleth": [ | |
{ | |
"colorbar": { | |
"outlinewidth": 0, | |
"ticks": "" | |
}, | |
"type": "choropleth" | |
} | |
], | |
"contour": [ | |
{ | |
"colorbar": { | |
"outlinewidth": 0, | |
"ticks": "" | |
}, | |
"colorscale": [ | |
[ | |
0, | |
"#0d0887" | |
], | |
[ | |
0.1111111111111111, | |
"#46039f" | |
], | |
[ | |
0.2222222222222222, | |
"#7201a8" | |
], | |
[ | |
0.3333333333333333, | |
"#9c179e" | |
], | |
[ | |
0.4444444444444444, | |
"#bd3786" | |
], | |
[ | |
0.5555555555555556, | |
"#d8576b" | |
], | |
[ | |
0.6666666666666666, | |
"#ed7953" | |
], | |
[ | |
0.7777777777777778, | |
"#fb9f3a" | |
], | |
[ | |
0.8888888888888888, | |
"#fdca26" | |
], | |
[ | |
1, | |
"#f0f921" | |
] | |
], | |
"type": "contour" | |
} | |
], | |
"contourcarpet": [ | |
{ | |
"colorbar": { | |
"outlinewidth": 0, | |
"ticks": "" | |
}, | |
"type": "contourcarpet" | |
} | |
], | |
"heatmap": [ | |
{ | |
"colorbar": { | |
"outlinewidth": 0, | |
"ticks": "" | |
}, | |
"colorscale": [ | |
[ | |
0, | |
"#0d0887" | |
], | |
[ | |
0.1111111111111111, | |
"#46039f" | |
], | |
[ | |
0.2222222222222222, | |
"#7201a8" | |
], | |
[ | |
0.3333333333333333, | |
"#9c179e" | |
], | |
[ | |
0.4444444444444444, | |
"#bd3786" | |
], | |
[ | |
0.5555555555555556, | |
"#d8576b" | |
], | |
[ | |
0.6666666666666666, | |
"#ed7953" | |
], | |
[ | |
0.7777777777777778, | |
"#fb9f3a" | |
], | |
[ | |
0.8888888888888888, | |
"#fdca26" | |
], | |
[ | |
1, | |
"#f0f921" | |
] | |
], | |
"type": "heatmap" | |
} | |
], | |
"heatmapgl": [ | |
{ | |
"colorbar": { | |
"outlinewidth": 0, | |
"ticks": "" | |
}, | |
"colorscale": [ | |
[ | |
0, | |
"#0d0887" | |
], | |
[ | |
0.1111111111111111, | |
"#46039f" | |
], | |
[ | |
0.2222222222222222, | |
"#7201a8" | |
], | |
[ | |
0.3333333333333333, | |
"#9c179e" | |
], | |
[ | |
0.4444444444444444, | |
"#bd3786" | |
], | |
[ | |
0.5555555555555556, | |
"#d8576b" | |
], | |
[ | |
0.6666666666666666, | |
"#ed7953" | |
], | |
[ | |
0.7777777777777778, | |
"#fb9f3a" | |
], | |
[ | |
0.8888888888888888, | |
"#fdca26" | |
], | |
[ | |
1, | |
"#f0f921" | |
] | |
], | |
"type": "heatmapgl" | |
} | |
], | |
"histogram": [ | |
{ | |
"marker": { | |
"pattern": { | |
"fillmode": "overlay", | |
"size": 10, | |
"solidity": 0.2 | |
} | |
}, | |
"type": "histogram" | |
} | |
], | |
"histogram2d": [ | |
{ | |
"colorbar": { | |
"outlinewidth": 0, | |
"ticks": "" | |
}, | |
"colorscale": [ | |
[ | |
0, | |
"#0d0887" | |
], | |
[ | |
0.1111111111111111, | |
"#46039f" | |
], | |
[ | |
0.2222222222222222, | |
"#7201a8" | |
], | |
[ | |
0.3333333333333333, | |
"#9c179e" | |
], | |
[ | |
0.4444444444444444, | |
"#bd3786" | |
], | |
[ | |
0.5555555555555556, | |
"#d8576b" | |
], | |
[ | |
0.6666666666666666, | |
"#ed7953" | |
], | |
[ | |
0.7777777777777778, | |
"#fb9f3a" | |
], | |
[ | |
0.8888888888888888, | |
"#fdca26" | |
], | |
[ | |
1, | |
"#f0f921" | |
] | |
], | |
"type": "histogram2d" | |
} | |
], | |
"histogram2dcontour": [ | |
{ | |
"colorbar": { | |
"outlinewidth": 0, | |
"ticks": "" | |
}, | |
"colorscale": [ | |
[ | |
0, | |
"#0d0887" | |
], | |
[ | |
0.1111111111111111, | |
"#46039f" | |
], | |
[ | |
0.2222222222222222, | |
"#7201a8" | |
], | |
[ | |
0.3333333333333333, | |
"#9c179e" | |
], | |
[ | |
0.4444444444444444, | |
"#bd3786" | |
], | |
[ | |
0.5555555555555556, | |
"#d8576b" | |
], | |
[ | |
0.6666666666666666, | |
"#ed7953" | |
], | |
[ | |
0.7777777777777778, | |
"#fb9f3a" | |
], | |
[ | |
0.8888888888888888, | |
"#fdca26" | |
], | |
[ | |
1, | |
"#f0f921" | |
] | |
], | |
"type": "histogram2dcontour" | |
} | |
], | |
"mesh3d": [ | |
{ | |
"colorbar": { | |
"outlinewidth": 0, | |
"ticks": "" | |
}, | |
"type": "mesh3d" | |
} | |
], | |
"parcoords": [ | |
{ | |
"line": { | |
"colorbar": { | |
"outlinewidth": 0, | |
"ticks": "" | |
} | |
}, | |
"type": "parcoords" | |
} | |
], | |
"pie": [ | |
{ | |
"automargin": true, | |
"type": "pie" | |
} | |
], | |
"scatter": [ | |
{ | |
"marker": { | |
"colorbar": { | |
"outlinewidth": 0, | |
"ticks": "" | |
} | |
}, | |
"type": "scatter" | |
} | |
], | |
"scatter3d": [ | |
{ | |
"line": { | |
"colorbar": { | |
"outlinewidth": 0, | |
"ticks": "" | |
} | |
}, | |
"marker": { | |
"colorbar": { | |
"outlinewidth": 0, | |
"ticks": "" | |
} | |
}, | |
"type": "scatter3d" | |
} | |
], | |
"scattercarpet": [ | |
{ | |
"marker": { | |
"colorbar": { | |
"outlinewidth": 0, | |
"ticks": "" | |
} | |
}, | |
"type": "scattercarpet" | |
} | |
], | |
"scattergeo": [ | |
{ | |
"marker": { | |
"colorbar": { | |
"outlinewidth": 0, | |
"ticks": "" | |
} | |
}, | |
"type": "scattergeo" | |
} | |
], | |
"scattergl": [ | |
{ | |
"marker": { | |
"colorbar": { | |
"outlinewidth": 0, | |
"ticks": "" | |
} | |
}, | |
"type": "scattergl" | |
} | |
], | |
"scattermapbox": [ | |
{ | |
"marker": { | |
"colorbar": { | |
"outlinewidth": 0, | |
"ticks": "" | |
} | |
}, | |
"type": "scattermapbox" | |
} | |
], | |
"scatterpolar": [ | |
{ | |
"marker": { | |
"colorbar": { | |
"outlinewidth": 0, | |
"ticks": "" | |
} | |
}, | |
"type": "scatterpolar" | |
} | |
], | |
"scatterpolargl": [ | |
{ | |
"marker": { | |
"colorbar": { | |
"outlinewidth": 0, | |
"ticks": "" | |
} | |
}, | |
"type": "scatterpolargl" | |
} | |
], | |
"scatterternary": [ | |
{ | |
"marker": { | |
"colorbar": { | |
"outlinewidth": 0, | |
"ticks": "" | |
} | |
}, | |
"type": "scatterternary" | |
} | |
], | |
"surface": [ | |
{ | |
"colorbar": { | |
"outlinewidth": 0, | |
"ticks": "" | |
}, | |
"colorscale": [ | |
[ | |
0, | |
"#0d0887" | |
], | |
[ | |
0.1111111111111111, | |
"#46039f" | |
], | |
[ | |
0.2222222222222222, | |
"#7201a8" | |
], | |
[ | |
0.3333333333333333, | |
"#9c179e" | |
], | |
[ | |
0.4444444444444444, | |
"#bd3786" | |
], | |
[ | |
0.5555555555555556, | |
"#d8576b" | |
], | |
[ | |
0.6666666666666666, | |
"#ed7953" | |
], | |
[ | |
0.7777777777777778, | |
"#fb9f3a" | |
], | |
[ | |
0.8888888888888888, | |
"#fdca26" | |
], | |
[ | |
1, | |
"#f0f921" | |
] | |
], | |
"type": "surface" | |
} | |
], | |
"table": [ | |
{ | |
"cells": { | |
"fill": { | |
"color": "#EBF0F8" | |
}, | |
"line": { | |
"color": "white" | |
} | |
}, | |
"header": { | |
"fill": { | |
"color": "#C8D4E3" | |
}, | |
"line": { | |
"color": "white" | |
} | |
}, | |
"type": "table" | |
} | |
] | |
}, | |
"layout": { | |
"annotationdefaults": { | |
"arrowcolor": "#2a3f5f", | |
"arrowhead": 0, | |
"arrowwidth": 1 | |
}, | |
"autotypenumbers": "strict", | |
"coloraxis": { | |
"colorbar": { | |
"outlinewidth": 0, | |
"ticks": "" | |
} | |
}, | |
"colorscale": { | |
"diverging": [ | |
[ | |
0, | |
"#8e0152" | |
], | |
[ | |
0.1, | |
"#c51b7d" | |
], | |
[ | |
0.2, | |
"#de77ae" | |
], | |
[ | |
0.3, | |
"#f1b6da" | |
], | |
[ | |
0.4, | |
"#fde0ef" | |
], | |
[ | |
0.5, | |
"#f7f7f7" | |
], | |
[ | |
0.6, | |
"#e6f5d0" | |
], | |
[ | |
0.7, | |
"#b8e186" | |
], | |
[ | |
0.8, | |
"#7fbc41" | |
], | |
[ | |
0.9, | |
"#4d9221" | |
], | |
[ | |
1, | |
"#276419" | |
] | |
], | |
"sequential": [ | |
[ | |
0, | |
"#0d0887" | |
], | |
[ | |
0.1111111111111111, | |
"#46039f" | |
], | |
[ | |
0.2222222222222222, | |
"#7201a8" | |
], | |
[ | |
0.3333333333333333, | |
"#9c179e" | |
], | |
[ | |
0.4444444444444444, | |
"#bd3786" | |
], | |
[ | |
0.5555555555555556, | |
"#d8576b" | |
], | |
[ | |
0.6666666666666666, | |
"#ed7953" | |
], | |
[ | |
0.7777777777777778, | |
"#fb9f3a" | |
], | |
[ | |
0.8888888888888888, | |
"#fdca26" | |
], | |
[ | |
1, | |
"#f0f921" | |
] | |
], | |
"sequentialminus": [ | |
[ | |
0, | |
"#0d0887" | |
], | |
[ | |
0.1111111111111111, | |
"#46039f" | |
], | |
[ | |
0.2222222222222222, | |
"#7201a8" | |
], | |
[ | |
0.3333333333333333, | |
"#9c179e" | |
], | |
[ | |
0.4444444444444444, | |
"#bd3786" | |
], | |
[ | |
0.5555555555555556, | |
"#d8576b" | |
], | |
[ | |
0.6666666666666666, | |
"#ed7953" | |
], | |
[ | |
0.7777777777777778, | |
"#fb9f3a" | |
], | |
[ | |
0.8888888888888888, | |
"#fdca26" | |
], | |
[ | |
1, | |
"#f0f921" | |
] | |
] | |
}, | |
"colorway": [ | |
"#636efa", | |
"#EF553B", | |
"#00cc96", | |
"#ab63fa", | |
"#FFA15A", | |
"#19d3f3", | |
"#FF6692", | |
"#B6E880", | |
"#FF97FF", | |
"#FECB52" | |
], | |
"font": { | |
"color": "#2a3f5f" | |
}, | |
"geo": { | |
"bgcolor": "white", | |
"lakecolor": "white", | |
"landcolor": "#E5ECF6", | |
"showlakes": true, | |
"showland": true, | |
"subunitcolor": "white" | |
}, | |
"hoverlabel": { | |
"align": "left" | |
}, | |
"hovermode": "closest", | |
"mapbox": { | |
"style": "light" | |
}, | |
"paper_bgcolor": "white", | |
"plot_bgcolor": "#E5ECF6", | |
"polar": { | |
"angularaxis": { | |
"gridcolor": "white", | |
"linecolor": "white", | |
"ticks": "" | |
}, | |
"bgcolor": "#E5ECF6", | |
"radialaxis": { | |
"gridcolor": "white", | |
"linecolor": "white", | |
"ticks": "" | |
} | |
}, | |
"scene": { | |
"xaxis": { | |
"backgroundcolor": "#E5ECF6", | |
"gridcolor": "white", | |
"gridwidth": 2, | |
"linecolor": "white", | |
"showbackground": true, | |
"ticks": "", | |
"zerolinecolor": "white" | |
}, | |
"yaxis": { | |
"backgroundcolor": "#E5ECF6", | |
"gridcolor": "white", | |
"gridwidth": 2, | |
"linecolor": "white", | |
"showbackground": true, | |
"ticks": "", | |
"zerolinecolor": "white" | |
}, | |
"zaxis": { | |
"backgroundcolor": "#E5ECF6", | |
"gridcolor": "white", | |
"gridwidth": 2, | |
"linecolor": "white", | |
"showbackground": true, | |
"ticks": "", | |
"zerolinecolor": "white" | |
} | |
}, | |
"shapedefaults": { | |
"line": { | |
"color": "#2a3f5f" | |
} | |
}, | |
"ternary": { | |
"aaxis": { | |
"gridcolor": "white", | |
"linecolor": "white", | |
"ticks": "" | |
}, | |
"baxis": { | |
"gridcolor": "white", | |
"linecolor": "white", | |
"ticks": "" | |
}, | |
"bgcolor": "#E5ECF6", | |
"caxis": { | |
"gridcolor": "white", | |
"linecolor": "white", | |
"ticks": "" | |
} | |
}, | |
"title": { | |
"x": 0.05 | |
}, | |
"xaxis": { | |
"automargin": true, | |
"gridcolor": "white", | |
"linecolor": "white", | |
"ticks": "", | |
"title": { | |
"standoff": 15 | |
}, | |
"zerolinecolor": "white", | |
"zerolinewidth": 2 | |
}, | |
"yaxis": { | |
"automargin": true, | |
"gridcolor": "white", | |
"linecolor": "white", | |
"ticks": "", | |
"title": { | |
"standoff": 15 | |
}, | |
"zerolinecolor": "white", | |
"zerolinewidth": 2 | |
} | |
} | |
}, | |
"title": { | |
"text": "Keyword Web Search Interest Over Time" | |
}, | |
"xaxis": { | |
"anchor": "y", | |
"domain": [ | |
0, | |
1 | |
], | |
"title": { | |
"text": "date" | |
} | |
}, | |
"yaxis": { | |
"anchor": "x", | |
"domain": [ | |
0, | |
1 | |
], | |
"title": { | |
"text": "value" | |
} | |
} | |
} | |
}, | |
"text/html": [ | |
"<div> <div id=\"bc0708dc-1834-41dd-a57a-5cc2ac717fb7\" class=\"plotly-graph-div\" style=\"height:525px; width:100%;\"></div> <script type=\"text/javascript\"> require([\"plotly\"], function(Plotly) { window.PLOTLYENV=window.PLOTLYENV || {}; if (document.getElementById(\"bc0708dc-1834-41dd-a57a-5cc2ac717fb7\")) { Plotly.newPlot( \"bc0708dc-1834-41dd-a57a-5cc2ac717fb7\", [{\"hovertemplate\":\"variable=machine learning<br>date=%{x}<br>value=%{y}<extra></extra>\",\"legendgroup\":\"machine learning\",\"line\":{\"color\":\"#636efa\",\"dash\":\"solid\"},\"marker\":{\"symbol\":\"circle\"},\"mode\":\"lines\",\"name\":\"machine learning\",\"orientation\":\"v\",\"showlegend\":true,\"type\":\"scatter\",\"x\":[\"2020-11-08T00:00:00\",\"2020-11-15T00:00:00\",\"2020-11-22T00:00:00\",\"2020-11-29T00:00:00\",\"2020-12-06T00:00:00\",\"2020-12-13T00:00:00\",\"2020-12-20T00:00:00\",\"2020-12-27T00:00:00\",\"2021-01-03T00:00:00\",\"2021-01-10T00:00:00\",\"2021-01-17T00:00:00\",\"2021-01-24T00:00:00\",\"2021-01-31T00:00:00\",\"2021-02-07T00:00:00\",\"2021-02-14T00:00:00\",\"2021-02-21T00:00:00\",\"2021-02-28T00:00:00\",\"2021-03-07T00:00:00\",\"2021-03-14T00:00:00\",\"2021-03-21T00:00:00\",\"2021-03-28T00:00:00\",\"2021-04-04T00:00:00\",\"2021-04-11T00:00:00\",\"2021-04-18T00:00:00\",\"2021-04-25T00:00:00\",\"2021-05-02T00:00:00\",\"2021-05-09T00:00:00\",\"2021-05-16T00:00:00\",\"2021-05-23T00:00:00\",\"2021-05-30T00:00:00\",\"2021-06-06T00:00:00\",\"2021-06-13T00:00:00\",\"2021-06-20T00:00:00\",\"2021-06-27T00:00:00\",\"2021-07-04T00:00:00\",\"2021-07-11T00:00:00\",\"2021-07-18T00:00:00\",\"2021-07-25T00:00:00\",\"2021-08-01T00:00:00\",\"2021-08-08T00:00:00\",\"2021-08-15T00:00:00\",\"2021-08-22T00:00:00\",\"2021-08-29T00:00:00\",\"2021-09-05T00:00:00\",\"2021-09-12T00:00:00\",\"2021-09-19T00:00:00\",\"2021-09-26T00:00:00\",\"2021-10-03T00:00:00\",\"2021-10-10T00:00:00\",\"2021-10-17T00:00:00\",\"2021-10-24T00:00:00\",\"2021-10-31T00:00:00\"],\"xaxis\":\"x\",\"y\":[84,89,81,89,95,83,73,73,80,85,89,87,91,83,86,89,93,90,94,89,84,87,85,96,87,87,82,88,92,91,81,92,94,90,85,92,91,89,81,89,82,87,82,84,92,91,100,100,90,87,99,89],\"yaxis\":\"y\"}], {\"legend\":{\"title\":{\"text\":\"variable\"},\"tracegroupgap\":0},\"template\":{\"data\":{\"bar\":[{\"error_x\":{\"color\":\"#2a3f5f\"},\"error_y\":{\"color\":\"#2a3f5f\"},\"marker\":{\"line\":{\"color\":\"#E5ECF6\",\"width\":0.5},\"pattern\":{\"fillmode\":\"overlay\",\"size\":10,\"solidity\":0.2}},\"type\":\"bar\"}],\"barpolar\":[{\"marker\":{\"line\":{\"color\":\"#E5ECF6\",\"width\":0.5},\"pattern\":{\"fillmode\":\"overlay\",\"size\":10,\"solidity\":0.2}},\"type\":\"barpolar\"}],\"carpet\":[{\"aaxis\":{\"endlinecolor\":\"#2a3f5f\",\"gridcolor\":\"white\",\"linecolor\":\"white\",\"minorgridcolor\":\"white\",\"startlinecolor\":\"#2a3f5f\"},\"baxis\":{\"endlinecolor\":\"#2a3f5f\",\"gridcolor\":\"white\",\"linecolor\":\"white\",\"minorgridcolor\":\"white\",\"startlinecolor\":\"#2a3f5f\"},\"type\":\"carpet\"}],\"choropleth\":[{\"colorbar\":{\"outlinewidth\":0,\"ticks\":\"\"},\"type\":\"choropleth\"}],\"contour\":[{\"colorbar\":{\"outlinewidth\":0,\"ticks\":\"\"},\"colorscale\":[[0.0,\"#0d0887\"],[0.1111111111111111,\"#46039f\"],[0.2222222222222222,\"#7201a8\"],[0.3333333333333333,\"#9c179e\"],[0.4444444444444444,\"#bd3786\"],[0.5555555555555556,\"#d8576b\"],[0.6666666666666666,\"#ed7953\"],[0.7777777777777778,\"#fb9f3a\"],[0.8888888888888888,\"#fdca26\"],[1.0,\"#f0f921\"]],\"type\":\"contour\"}],\"contourcarpet\":[{\"colorbar\":{\"outlinewidth\":0,\"ticks\":\"\"},\"type\":\"contourcarpet\"}],\"heatmap\":[{\"colorbar\":{\"outlinewidth\":0,\"ticks\":\"\"},\"colorscale\":[[0.0,\"#0d0887\"],[0.1111111111111111,\"#46039f\"],[0.2222222222222222,\"#7201a8\"],[0.3333333333333333,\"#9c179e\"],[0.4444444444444444,\"#bd3786\"],[0.5555555555555556,\"#d8576b\"],[0.6666666666666666,\"#ed7953\"],[0.7777777777777778,\"#fb9f3a\"],[0.8888888888888888,\"#fdca26\"],[1.0,\"#f0f921\"]],\"type\":\"heatmap\"}],\"heatmapgl\":[{\"colorbar\":{\"outlinewidth\":0,\"ticks\":\"\"},\"colorscale\":[[0.0,\"#0d0887\"],[0.1111111111111111,\"#46039f\"],[0.2222222222222222,\"#7201a8\"],[0.3333333333333333,\"#9c179e\"],[0.4444444444444444,\"#bd3786\"],[0.5555555555555556,\"#d8576b\"],[0.6666666666666666,\"#ed7953\"],[0.7777777777777778,\"#fb9f3a\"],[0.8888888888888888,\"#fdca26\"],[1.0,\"#f0f921\"]],\"type\":\"heatmapgl\"}],\"histogram\":[{\"marker\":{\"pattern\":{\"fillmode\":\"overlay\",\"size\":10,\"solidity\":0.2}},\"type\":\"histogram\"}],\"histogram2d\":[{\"colorbar\":{\"outlinewidth\":0,\"ticks\":\"\"},\"colorscale\":[[0.0,\"#0d0887\"],[0.1111111111111111,\"#46039f\"],[0.2222222222222222,\"#7201a8\"],[0.3333333333333333,\"#9c179e\"],[0.4444444444444444,\"#bd3786\"],[0.5555555555555556,\"#d8576b\"],[0.6666666666666666,\"#ed7953\"],[0.7777777777777778,\"#fb9f3a\"],[0.8888888888888888,\"#fdca26\"],[1.0,\"#f0f921\"]],\"type\":\"histogram2d\"}],\"histogram2dcontour\":[{\"colorbar\":{\"outlinewidth\":0,\"ticks\":\"\"},\"colorscale\":[[0.0,\"#0d0887\"],[0.1111111111111111,\"#46039f\"],[0.2222222222222222,\"#7201a8\"],[0.3333333333333333,\"#9c179e\"],[0.4444444444444444,\"#bd3786\"],[0.5555555555555556,\"#d8576b\"],[0.6666666666666666,\"#ed7953\"],[0.7777777777777778,\"#fb9f3a\"],[0.8888888888888888,\"#fdca26\"],[1.0,\"#f0f921\"]],\"type\":\"histogram2dcontour\"}],\"mesh3d\":[{\"colorbar\":{\"outlinewidth\":0,\"ticks\":\"\"},\"type\":\"mesh3d\"}],\"parcoords\":[{\"line\":{\"colorbar\":{\"outlinewidth\":0,\"ticks\":\"\"}},\"type\":\"parcoords\"}],\"pie\":[{\"automargin\":true,\"type\":\"pie\"}],\"scatter\":[{\"marker\":{\"colorbar\":{\"outlinewidth\":0,\"ticks\":\"\"}},\"type\":\"scatter\"}],\"scatter3d\":[{\"line\":{\"colorbar\":{\"outlinewidth\":0,\"ticks\":\"\"}},\"marker\":{\"colorbar\":{\"outlinewidth\":0,\"ticks\":\"\"}},\"type\":\"scatter3d\"}],\"scattercarpet\":[{\"marker\":{\"colorbar\":{\"outlinewidth\":0,\"ticks\":\"\"}},\"type\":\"scattercarpet\"}],\"scattergeo\":[{\"marker\":{\"colorbar\":{\"outlinewidth\":0,\"ticks\":\"\"}},\"type\":\"scattergeo\"}],\"scattergl\":[{\"marker\":{\"colorbar\":{\"outlinewidth\":0,\"ticks\":\"\"}},\"type\":\"scattergl\"}],\"scattermapbox\":[{\"marker\":{\"colorbar\":{\"outlinewidth\":0,\"ticks\":\"\"}},\"type\":\"scattermapbox\"}],\"scatterpolar\":[{\"marker\":{\"colorbar\":{\"outlinewidth\":0,\"ticks\":\"\"}},\"type\":\"scatterpolar\"}],\"scatterpolargl\":[{\"marker\":{\"colorbar\":{\"outlinewidth\":0,\"ticks\":\"\"}},\"type\":\"scatterpolargl\"}],\"scatterternary\":[{\"marker\":{\"colorbar\":{\"outlinewidth\":0,\"ticks\":\"\"}},\"type\":\"scatterternary\"}],\"surface\":[{\"colorbar\":{\"outlinewidth\":0,\"ticks\":\"\"},\"colorscale\":[[0.0,\"#0d0887\"],[0.1111111111111111,\"#46039f\"],[0.2222222222222222,\"#7201a8\"],[0.3333333333333333,\"#9c179e\"],[0.4444444444444444,\"#bd3786\"],[0.5555555555555556,\"#d8576b\"],[0.6666666666666666,\"#ed7953\"],[0.7777777777777778,\"#fb9f3a\"],[0.8888888888888888,\"#fdca26\"],[1.0,\"#f0f921\"]],\"type\":\"surface\"}],\"table\":[{\"cells\":{\"fill\":{\"color\":\"#EBF0F8\"},\"line\":{\"color\":\"white\"}},\"header\":{\"fill\":{\"color\":\"#C8D4E3\"},\"line\":{\"color\":\"white\"}},\"type\":\"table\"}]},\"layout\":{\"annotationdefaults\":{\"arrowcolor\":\"#2a3f5f\",\"arrowhead\":0,\"arrowwidth\":1},\"autotypenumbers\":\"strict\",\"coloraxis\":{\"colorbar\":{\"outlinewidth\":0,\"ticks\":\"\"}},\"colorscale\":{\"diverging\":[[0,\"#8e0152\"],[0.1,\"#c51b7d\"],[0.2,\"#de77ae\"],[0.3,\"#f1b6da\"],[0.4,\"#fde0ef\"],[0.5,\"#f7f7f7\"],[0.6,\"#e6f5d0\"],[0.7,\"#b8e186\"],[0.8,\"#7fbc41\"],[0.9,\"#4d9221\"],[1,\"#276419\"]],\"sequential\":[[0.0,\"#0d0887\"],[0.1111111111111111,\"#46039f\"],[0.2222222222222222,\"#7201a8\"],[0.3333333333333333,\"#9c179e\"],[0.4444444444444444,\"#bd3786\"],[0.5555555555555556,\"#d8576b\"],[0.6666666666666666,\"#ed7953\"],[0.7777777777777778,\"#fb9f3a\"],[0.8888888888888888,\"#fdca26\"],[1.0,\"#f0f921\"]],\"sequentialminus\":[[0.0,\"#0d0887\"],[0.1111111111111111,\"#46039f\"],[0.2222222222222222,\"#7201a8\"],[0.3333333333333333,\"#9c179e\"],[0.4444444444444444,\"#bd3786\"],[0.5555555555555556,\"#d8576b\"],[0.6666666666666666,\"#ed7953\"],[0.7777777777777778,\"#fb9f3a\"],[0.8888888888888888,\"#fdca26\"],[1.0,\"#f0f921\"]]},\"colorway\":[\"#636efa\",\"#EF553B\",\"#00cc96\",\"#ab63fa\",\"#FFA15A\",\"#19d3f3\",\"#FF6692\",\"#B6E880\",\"#FF97FF\",\"#FECB52\"],\"font\":{\"color\":\"#2a3f5f\"},\"geo\":{\"bgcolor\":\"white\",\"lakecolor\":\"white\",\"landcolor\":\"#E5ECF6\",\"showlakes\":true,\"showland\":true,\"subunitcolor\":\"white\"},\"hoverlabel\":{\"align\":\"left\"},\"hovermode\":\"closest\",\"mapbox\":{\"style\":\"light\"},\"paper_bgcolor\":\"white\",\"plot_bgcolor\":\"#E5ECF6\",\"polar\":{\"angularaxis\":{\"gridcolor\":\"white\",\"linecolor\":\"white\",\"ticks\":\"\"},\"bgcolor\":\"#E5ECF6\",\"radialaxis\":{\"gridcolor\":\"white\",\"linecolor\":\"white\",\"ticks\":\"\"}},\"scene\":{\"xaxis\":{\"backgroundcolor\":\"#E5ECF6\",\"gridcolor\":\"white\",\"gridwidth\":2,\"linecolor\":\"white\",\"showbackground\":true,\"ticks\":\"\",\"zerolinecolor\":\"white\"},\"yaxis\":{\"backgroundcolor\":\"#E5ECF6\",\"gridcolor\":\"white\",\"gridwidth\":2,\"linecolor\":\"white\",\"showbackground\":true,\"ticks\":\"\",\"zerolinecolor\":\"white\"},\"zaxis\":{\"backgroundcolor\":\"#E5ECF6\",\"gridcolor\":\"white\",\"gridwidth\":2,\"linecolor\":\"white\",\"showbackground\":true,\"ticks\":\"\",\"zerolinecolor\":\"white\"}},\"shapedefaults\":{\"line\":{\"color\":\"#2a3f5f\"}},\"ternary\":{\"aaxis\":{\"gridcolor\":\"white\",\"linecolor\":\"white\",\"ticks\":\"\"},\"baxis\":{\"gridcolor\":\"white\",\"linecolor\":\"white\",\"ticks\":\"\"},\"bgcolor\":\"#E5ECF6\",\"caxis\":{\"gridcolor\":\"white\",\"linecolor\":\"white\",\"ticks\":\"\"}},\"title\":{\"x\":0.05},\"xaxis\":{\"automargin\":true,\"gridcolor\":\"white\",\"linecolor\":\"white\",\"ticks\":\"\",\"title\":{\"standoff\":15},\"zerolinecolor\":\"white\",\"zerolinewidth\":2},\"yaxis\":{\"automargin\":true,\"gridcolor\":\"white\",\"linecolor\":\"white\",\"ticks\":\"\",\"title\":{\"standoff\":15},\"zerolinecolor\":\"white\",\"zerolinewidth\":2}}},\"title\":{\"text\":\"Keyword Web Search Interest Over Time\"},\"xaxis\":{\"anchor\":\"y\",\"domain\":[0.0,1.0],\"title\":{\"text\":\"date\"}},\"yaxis\":{\"anchor\":\"x\",\"domain\":[0.0,1.0],\"title\":{\"text\":\"value\"}}}, {\"responsive\": true} ).then(function(){\n", | |
" \n", | |
"var gd = document.getElementById('bc0708dc-1834-41dd-a57a-5cc2ac717fb7');\n", | |
"var x = new MutationObserver(function (mutations, observer) {{\n", | |
" var display = window.getComputedStyle(gd).display;\n", | |
" if (!display || display === 'none') {{\n", | |
" console.log([gd, 'removed!']);\n", | |
" Plotly.purge(gd);\n", | |
" observer.disconnect();\n", | |
" }}\n", | |
"}});\n", | |
"\n", | |
"// Listen for the removal of the full notebook cells\n", | |
"var notebookContainer = gd.closest('#notebook-container');\n", | |
"if (notebookContainer) {{\n", | |
" x.observe(notebookContainer, {childList: true});\n", | |
"}}\n", | |
"\n", | |
"// Listen for the clearing of the current output cell\n", | |
"var outputEl = gd.closest('.output');\n", | |
"if (outputEl) {{\n", | |
" x.observe(outputEl, {childList: true});\n", | |
"}}\n", | |
"\n", | |
" }) }; }); </script> </div>" | |
] | |
}, | |
"metadata": {}, | |
"output_type": "display_data" | |
} | |
], | |
"source": [ | |
"#1 Interest over Time\n", | |
"data = pytrends.interest_over_time() \n", | |
"data = data.reset_index()\n", | |
"\n", | |
"fig = px.line(data, x=\"date\", y=['machine learning'], \n", | |
"title='Keyword Web Search Interest Over Time')\n", | |
"fig.show()" | |
] | |
} | |
], | |
"metadata": { | |
"interpreter": { | |
"hash": "dd6cfff634836e40ef69caa6ffd03f56c58a3994946bdf9626c1bb21d6ede6e4" | |
}, | |
"kernelspec": { | |
"display_name": "Python 3 (ipykernel)", | |
"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.8.12" | |
}, | |
"orig_nbformat": 4 | |
}, | |
"nbformat": 4, | |
"nbformat_minor": 2 | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment