I write about my quantitative explorations in visualisation, data science, machine and deep learning here, as well as other random musings.
For more about me and my other interests, visit playgrd or socials below
This is a short and sweet writeup on one way of downloading data from Google Trends, which can be useful for spotting or monitoring trends. I use the library made available here. First, install pytrends.
pip install pytrends
The steps thereafter are simple. Say, we want to find trends relating to the cashtags of specific stocks, we can just run these steps.
selected_ticker = ['$AAPL']
sel_ticker_trends = pytrends.get_historical_interest(selected_ticker,
year_start=2020, month_start=1, day_start=1, hour_start=0,
year_end=2020, month_end=1, day_end=2, hour_end=0,
cat=0, geo='', gprop='', sleep=60)
Or if we want to find trends relating to specific keywords.
kw_list = ['singapore', 'singaporean']
keyword_trends = pytrends.get_historical_interest(kw_list,
year_start=2021, month_start=1, day_start=1, hour_start=0,
year_end=2021, month_end=1, day_end=2, hour_end=0,
cat=0, geo='', gprop='', sleep=60)
The notebook here has the full code.
And that’s it. Happy data explorations!