Feature Type
-
[X] Adding new functionality to pandas
-
[X] Changing existing functionality in pandas
-
[ ] Removing existing functionality in pandas
Problem Description
I would like to use tz_convert
to be able to convert from local time (some timestamps with daylight savings) to standard time (no timestamps with daylight savings) in locations which employ 30 and 45 minute shifts from UTC time.
Currently my understanding is that tz_convert
uses pytz. pytz.all_timezones
does not include any timezones with 30 or 45 minute shifts, so this may be a feature request for pytz.
https://www.timeanddate.com/time/time-zones-interesting.html
Feature Description
In [28]: pd.Timestamp('2015-1-1 00:00', tz=pytz.FixedOffset(120))
Out[28]: Timestamp('2015-01-01 00:00:00+0200', tz='pytz.FixedOffset(120)')
It seems like I can create timestamps with a fixed offset, but I cannot convert from an existing timestamp to a fixed offset.
test.tz_convert('pytz.FixedOffset(-330)')
Traceback (most recent call last):
File "/usr/lib/python3.8/code.py", line 90, in runcode
exec(code, self.locals)
File "<input>", line 1, in <module>
File "pandas/_libs/tslibs/timestamps.pyx", line 2205, in pandas._libs.tslibs.timestamps.Timestamp.tz_convert
File "pandas/_libs/tslibs/timezones.pyx", line 172, in pandas._libs.tslibs.timezones.maybe_get_tz
File "/media/H/Python/Nevados/TRACE/_env/lib/python3.8/site-packages/pytz/__init__.py", line 188, in timezone
raise UnknownTimeZoneError(zone)
pytz.exceptions.UnknownTimeZoneError: 'pytz.FixedOffset(-330)'
Alternative Solutions
I could put a feature request in with pytz instead.
Additional Context
Thank you!
Comment From: jbrockmendel
If you pass a pytz.FixedOffset object you should be OK. IIUC the trouble is in passing a string that pytz can't parse