5

i am very new in pytrends api from here

however i don't understand how to define the offset timezone. The tutorial goes like this

pytrends = TrendReq(hl='en-US', tz=360)

with documentation for the tz (i assume timezone)

tz :
Timezone Offset
For example US CST is '360'

and i have try searching everywhere but i just don't understand how US CST = 360. Please help me understand this. Also if possible i want to use Jakarta, Indonesia timezone which is UTC+7

Thanks

Vira Xeva
  • 163
  • 1
  • 9
  • 1
    nevermind, i found it here http://forbrains.co.uk/international_tools/earth_timezones – Vira Xeva Jul 15 '18 at 02:49
  • Hi Vira, I'm not sure how `-360 = 360`. According to that link, you should have used the `-360` value to represent US Central, `UTC-6`, and therefore `UTC+7` would be `420`. Right? – Pat Grady Dec 12 '18 at 18:54

1 Answers1

3

The link in the comments did not work for me directly(it goes to home page vs the data), so I wanted to repost for others having this issue with pytrends. The question asker @vira-xeva provided the solution:

To find your target timezone, you want to use the minutes representation of the timezone, but WITHOUT the negative(see below). You can find your timezone here in this table: https://forbrains.co.uk/international_tools/earth_timezones

Remember to drop the negative(no clue why, googles convention according to pytrends mentioned in docs). From the tz section of Connect to Google:

"For example US CST is '360' (note NOT -360, Google uses timezone this way...)" https://pypi.org/project/pytrends/#api

Working Example:

from pytrends.request import TrendReq

# connect to google and get EST time zone
# If you see error like this, you are rate limted, wait a minute (see pytrends docs re proxies)
# HTTPSConnectionPool(host='trends.google.com', port=443): Read timed out. (read timeout=5)
pytrends = TrendReq(hl='en-US', tz=300)

kw_list = ['Thank You OP']

# Test via a 1 hour download of SPY keyword
result = pytrends.get_historical_interest(kw_list, 
                                 year_start=2018, 
                                 month_start=1, 
                                 day_start=1, 
                                 hour_start=0, 
                                 year_end=2018, 
                                 month_end=1, 
                                 day_end=1, 
                                 hour_end=0, 
                                 cat=0, 
                                 geo='', 
                                 gprop='', 
                                 sleep=0)

print(result)

# Resuls come as a Pandas DataFrame
'''
            Thank You OP  isPartial
date                               
2018-01-01             0      False
'''
DMTishler
  • 501
  • 1
  • 6
  • 12