pytrends icon indicating copy to clipboard operation
pytrends copied to clipboard

Pytrend interest over time by city/dma

Open Josh1punch opened this issue 4 years ago • 5 comments

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.

Josh1punch avatar Jul 13 '20 22:07 Josh1punch

Once I changed the request py, next time I run it will not do anything anymore.

Josh1punch avatar Jul 13 '20 22:07 Josh1punch

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"

GiovanniColonni avatar Nov 17 '20 08:11 GiovanniColonni

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 avatar Jan 12 '21 16:01 vbadita

@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

manisci avatar Aug 02 '22 17:08 manisci

@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

RyanBK avatar Feb 15 '24 03:02 RyanBK