Finding changes in search trend patterns
Search trends are not a static variable; in fact, they change and vary over time. We will get the results of the interest by region in the last 3 months and then we will look at changes in the results compared to the ones obtained over a period of 12 months:
- To find the changes in search trends patterns, we will build the payload within a different timeframe.
- Finally, we will store the results in a
pandas
DataFrame namedregiondf_3m
:#search interest per region
pytrend = TrendReq()
pytrend.build_payload(kw_list, timeframe='today 3-m')
# Interest by Region
regiondf_3m = pytrend.interest_by_region()
- We need to remove the rows that don’t have results for the search terms specified:
# #looking at rows where all values are not equal to 0
regiondf_3m = regiondf_3m[regiondf_3m.sum(axis=1)!=0]
- Now, we can visualize the results using the
plot
method of thepandas
DataFrame:# visualize
regiondf_3m.plot(figsize=(14, 8), y=kw_list...