Skip to content

Commit 2e86151

Browse files
committed
BUG: python 3 tzoffset is not hashable
1 parent 01eab0b commit 2e86151

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

pandas/src/datetime.pyx

+13
Original file line numberDiff line numberDiff line change
@@ -1005,6 +1005,12 @@ def _get_transitions(tz):
10051005
"""
10061006
Get UTC times of DST transitions
10071007
"""
1008+
try:
1009+
# tzoffset not hashable in Python 3
1010+
hash(tz)
1011+
except TypeError:
1012+
return np.array([NPY_NAT + 1], dtype=np.int64)
1013+
10081014
if tz not in trans_cache:
10091015
if hasattr(tz, '_utc_transition_times'):
10101016
arr = np.array(tz._utc_transition_times, dtype='M8[ns]')
@@ -1018,6 +1024,13 @@ def _get_deltas(tz):
10181024
"""
10191025
Get UTC offsets in microseconds corresponding to DST transitions
10201026
"""
1027+
try:
1028+
# tzoffset not hashable in Python 3
1029+
hash(tz)
1030+
except TypeError:
1031+
num = int(total_seconds(_get_utcoffset(tz))) * 1000000000
1032+
return np.array([num], dtype=np.int64)
1033+
10211034
if tz not in utc_offset_cache:
10221035
if hasattr(tz, '_utc_transition_times'):
10231036
utc_offset_cache[tz] = _unbox_utcoffsets(tz._transition_info)

0 commit comments

Comments
 (0)