epfl-dlab / GoogleTrendsAnchorBank

Google Trends, made easy.
MIT License
101 stars 22 forks source link

Questions about data at metropolitan/city level #12

Closed ssiwakoti1994 closed 3 years ago

ssiwakoti1994 commented 3 years ago

We are researchers at Princeton University utilizing the g-tab google trends anchor bank recently. We have been able to access the google trends data at the US state level but were wondering if we could get to the metropolitan/city level. Could you please advise us on this?

Thank you so much!

Best, Sam

manoelhortaribeiro commented 3 years ago

Hey @ssiwakoti1994!

You can do it by simply using the area codes (like this: https://www.bennetyee.org/ucsd-pages/area.html).

The syntax is: "US-XX-YYY" where XX is the state (e.g., NJ) and YYY is the area code (e.g., 609).

Here is a stub on how you can make an anchorbank for the new jersey area:

import gtab
t = gtab.GTAB()
t.set_options(pytrends_config={"geo": "US-NJ-609", "timeframe": "2004-01-01 2020-12-31"})
t.create_anchorbank() # takes a while to run since it queries Google Trends.