pytrends
pytrends copied to clipboard
Pytrend interest over time by city/dma
Currently the lowest level of geo we can get from pytrend is by State.
In order to get to dma/city we need to tune the request.py a little.
Once I changed the request py, next time I run it will not do anything anymore.
how can i tune the request in order to get data with city granularity ? i'm currently use pytrends 4.7.3, the geo parameter is set to "IT"
how can i tune the request in order to get data with city granularity ? i'm currently use pytrends 4.7.3, the geo parameter is set to "IT"
City not supported for IT. Only region
{ "default": { "geoMapData": [ { "formattedValue": [ "100" ], "geoCode": "IT-23", "geoName": "Valle d' Aosta", "hasData": [ true ], "maxValueIndex": 0, "value": [ 100 ] }, { "formattedValue": [ "62" ], "geoCode": "IT-57", "geoName": "Marche", "hasData": [ true ], "maxValueIndex": 0, "value": [ 62 ] }, { "formattedValue": [ "59" ], "geoCode": "IT-25", "geoName": "Lombardia", "hasData": [ true ], "maxValueIndex": 0, "value": [ 59 ] }, { "formattedValue": [ "58" ], "geoCode": "IT-45", "geoName": "Emilia-Romagna", "hasData": [ true ], "maxValueIndex": 0, "value": [ 58 ] }, { "formattedValue": [ "57" ], "geoCode": "IT-32", "geoName": "Trentino-Tirolul de Sud", "hasData": [ true ], "maxValueIndex": 0, "value": [ 57 ] }, { "formattedValue": [ "57" ], "geoCode": "IT-42", "geoName": "Liguria", "hasData": [ true ], "maxValueIndex": 0, "value": [ 57 ] }, { "formattedValue": [ "57" ], "geoCode": "IT-36", "geoName": "Friuli-Veneția Giulia", "hasData": [ true ], "maxValueIndex": 0, "value": [ 57 ] }, { "formattedValue": [ "55" ], "geoCode": "IT-52", "geoName": "Toscana", "hasData": [ true ], "maxValueIndex": 0, "value": [ 55 ] }, { "formattedValue": [ "53" ], "geoCode": "IT-55", "geoName": "Umbria", "hasData": [ true ], "maxValueIndex": 0, "value": [ 53 ] }, { "formattedValue": [ "51" ], "geoCode": "IT-34", "geoName": "Veneto", "hasData": [ true ], "maxValueIndex": 0, "value": [ 51 ] }, { "formattedValue": [ "51" ], "geoCode": "IT-62", "geoName": "Lazio", "hasData": [ true ], "maxValueIndex": 0, "value": [ 51 ] }, { "formattedValue": [ "50" ], "geoCode": "IT-21", "geoName": "Piemont", "hasData": [ true ], "maxValueIndex": 0, "value": [ 50 ] }, { "formattedValue": [ "49" ], "geoCode": "IT-67", "geoName": "Molise", "hasData": [ true ], "maxValueIndex": 0, "value": [ 49 ] }, { "formattedValue": [ "46" ], "geoCode": "IT-88", "geoName": "Sardinia", "hasData": [ true ], "maxValueIndex": 0, "value": [ 46 ] }, { "formattedValue": [ "42" ], "geoCode": "IT-77", "geoName": "Basilicata", "hasData": [ true ], "maxValueIndex": 0, "value": [ 42 ] }, { "formattedValue": [ "42" ], "geoCode": "IT-82", "geoName": "Sicilia", "hasData": [ true ], "maxValueIndex": 0, "value": [ 42 ] }, { "formattedValue": [ "41" ], "geoCode": "IT-65", "geoName": "Abruzzo", "hasData": [ true ], "maxValueIndex": 0, "value": [ 41 ] }, { "formattedValue": [ "40" ], "geoCode": "IT-75", "geoName": "Apulia", "hasData": [ true ], "maxValueIndex": 0, "value": [ 40 ] }, { "formattedValue": [ "39" ], "geoCode": "IT-72", "geoName": "Campania", "hasData": [ true ], "maxValueIndex": 0, "value": [ 39 ] }, { "formattedValue": [ "37" ], "geoCode": "IT-78", "geoName": "Calabria", "hasData": [ true ], "maxValueIndex": 0, "value": [ 37 ] } ] } }
@vbadita Hi. Can you tell me how did you get this dictionary? I'm trying to see what's the lowest resolution I can get for Canada, and it's been a headache. Are the valid geo codes the same as google ads data? This is the closest thing I have found to documentation for the geo field.
https://www.google.com/help/hc/downloads/sa360/Location-Language-Codes-GoogleAds.xlsx
@Josh1punch do you have any advice about obtaining interest over time by dma or city? If not, do you have any pointers about which file to work with to expand this functionality -- or is this a problem with the data not being shown anywhere on Google Trends?
from pytrends.request import TrendReq
keywords = ["movies"]
pytrends = TrendReq()
# pytrends.build_payload(keywords, timeframe='today 12-m', geo='US-WI') # Works
pytrends.build_payload(keywords, timeframe='today 12-m', geo='US-617') # Does not work
# Error: The request failed: Google returned a response with code 400
trend_data = pytrends.interest_over_time()
trend_data