Skip to content

Commit a8802b4

Browse files
author
Chang She
committed
BUG: reimplemented timedelta.total_seconds for Python26 compat
1 parent 3b76e9f commit a8802b4

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

pandas/src/datetime.pyx

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
# cython: profile=False
2-
32
cimport numpy as np
43
import numpy as np
54

@@ -830,6 +829,10 @@ def _get_deltas(object tz):
830829
utc_offset_cache[tz] = _unbox_utcoffsets(tz._transition_info)
831830
return utc_offset_cache[tz]
832831

832+
cdef double total_seconds(object td): # Python 2.6 compat
833+
return ((td.microseconds + (td.seconds + td.days * 24 * 3600) * 10**6) //
834+
10**6)
835+
833836
cdef ndarray _unbox_utcoffsets(object transinfo):
834837
cdef:
835838
Py_ssize_t i, sz
@@ -839,7 +842,7 @@ cdef ndarray _unbox_utcoffsets(object transinfo):
839842
arr = np.empty(sz, dtype='i8')
840843

841844
for i in range(sz):
842-
arr[i] = int(transinfo[i][0].total_seconds()) * 1000000
845+
arr[i] = int(total_seconds(transinfo[i][0])) * 1000000
843846

844847
return arr
845848

0 commit comments

Comments
 (0)