Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import numpy as np
- import pandas as pd
- from pytrends.request import TrendReq
- import pylab
- from hijri_converter import Hijri, Gregorian
- query = 'רקטות'
- pytrend = TrendReq()
- kw_list = [query]
- pytrend.build_payload(kw_list,
- timeframe='all')
- iot = pytrend.interest_over_time()
- search_months = pd.DatetimeIndex(iot.index).month
- search_years = pd.DatetimeIndex(iot.index).year
- tally = np.zeros(12)
- htally = np.zeros(12)
- for year, month, searches in zip(
- search_years,
- search_months,
- iot[query].values):
- tally[month-1] += searches
- h = Gregorian(year, month, 15).to_hijri()
- htally[h.month-1] += searches
- # Plotting
- pylab.subplot(211)
- pylab.bar(list(range(1, 13)),
- tally)
- pylab.title('Google trends for '+query[::-1]+' since 2004')
- pylab.xlabel('Gregorian month')
- pylab.subplot(212)
- pylab.bar(list(range(1, 13)),
- htally)
- pylab.xlabel('Islamic month')
- pylab.tight_layout()
- pylab.show()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement