2017-01-24 45 views
0

我有一個Python 2.7 ndarray(時間序列值)的格式:轉換時間序列

18631 23:18 

我在努力尋找一種簡單的方法將其轉換爲與total_seconds()

類似一個int

謝謝

+0

請您解釋一下'18631'的意義嗎? –

回答

1

不太確定確切的問題是什麼要求。我假設你想將23:18轉換爲當天的秒數?

import numpy as np 

time_stamp = np.array([18631, "23:18"]) 
time_day = time_stamp[1] 
h, m = [int(i) for i in time_day.split(":")] 
print "Seconds elapsed for day = %d" % (3600*h + 60*m) 
+0

謝謝KJ!這真的有幫助 –