WillKoehrsen / Data-Analysis

Data Science Using Python

Home Page:https://medium.com/@williamkoehrsen/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Search Terms not Coming Up when google trends has them

MacroMuppet opened this issue · comments

commented

Hi! Thanks for all your work. Great script.

When analyzing the CHGG stock vs search term Chegg I get an error ( full error below).

It doesn't give the failed "There are no search terms" because there are search terms ( link to term, https://trends.google.com/trends/explore?date=today%205-y&geo=US&q=chegg ).

But it won't take that search results and index it to the chart... it works for AMZN and Microsoft and broader search terms ie (college) but it yields electoral college, and college football as search terms.

Thanks for all your help in advance.


AttributeError Traceback (most recent call last)
in
----> 1 chegg.changepoint_date_analysis(search = 'chegg')

~\Projects\stocker.py in changepoint_date_analysis(self, search)
779
780 print('\n Top Related Queries: \n')
--> 781 #print(related_queries[search]['top'].head())
782
783 print('\n Rising Related Queries: \n')

AttributeError: 'NoneType' object has no attribute 'head'

commented

Fixed.
Original Code:....
Line 688 pytrends.build_payload(kw_list, cat=0, timeframe=date_range[0], geo='', gprop='news')

Fixed Code (DELETE BOLD)....
Line 688 pytrends.build_payload(kw_list, cat=0, timeframe=date_range[0], geo='', gprop='news')

Yes, I setup pytrends to search for news by default. If you are searching for a topic that won't appear in the news, you'll need to change the code. Thanks for the fix!