I´m strugeling a bit with Pytrends, specifically the TZ. When changing the timezones, it does not change the timestamp in the output.
pytrends = TrendReq(hl = 'en-US', tz = 120)
keywords = ['lei', 'lei code', 'legal entity identifier']
data = pytrends.get_historical_interest(keywords, year_start=2021, month_start=5, day_start=30,
hour_start=0, year_end=2021, month_end=6, day_end=1,
hour_end=0, geo='IE', gprop='', sleep=0)
data
Output:
date lei lei code legal entity identifier isPartial
2021-05-31 07:00:00 54 0 0 False
2021-05-31 08:00:00 44 13 0 False
2021-05-31 09:00:00 33 0 0 False
2021-05-31 10:00:00 74 0 0 True
If I then change the timezone (tz) the output is the same
pytrends = TrendReq(hl = 'en-US', tz = 0)
keywords = ['lei', 'lei code', 'legal entity identifier']
data = pytrends.get_historical_interest(keywords, year_start=2021, month_start=5, day_start=30,
hour_start=0, year_end=2021, month_end=6, day_end=1,
hour_end=0, geo='IE', gprop='', sleep=0)
data
Output:
date lei lei code legal entity identifier isPartial
2021-05-31 07:00:00 54 0 0 False
2021-05-31 08:00:00 44 13 0 False
2021-05-31 09:00:00 33 0 0 False
2021-05-31 10:00:00 74 0 0 True
Probably something obvious I'm missing but how can I make the times change with the timezones. Was thinking about just lagging the output after.
With regards K
Google is returning the results in UTC format, You can use this code as an alternative to convert UTC to other timezone(For ex. EST )
from pytrends.request import TrendReq
import pytz
pytrends = TrendReq(hl = 'en-US', tz = 200)
keywords = ['lei', 'lei code', 'legal entity identifier']
data = pytrends.get_historical_interest(keywords, year_start=2021, month_start=5, day_start=30,
hour_start=0, year_end=2021, month_end=6, day_end=1,
hour_end=0, geo='IE', gprop='', sleep=0)
index = data.index
data.index = index.tz_localize(pytz.utc).tz_convert(pytz.timezone('EST')).tz_localize(None)
data
You can get list of timezones using this
pytz.all_timezones
Hope so this would solve your problem