我使用python的熊貓,我落得下表:日期格式熊貓 - Python的
+---------------------+----------------------+-----------------+
| start | finish | duration |
+---------------------+----------------------+-----------------+
| 2013-08-12 12:00:00 | 2013-08-14 16:00:00 | 2 days 04:00:00 |
+---------------------+----------------------+-----------------+
dataframe=dataframe.to_json(orient='records',date_format='iso',double_precision=2,date_unit='s')
return jsonify(data=dataframe)
我發這種過度使用AJAX請求作爲data
,並在JavaScript端我結束了data.duration = 1970-01-03T04:00:00Z
如何格式化數據幀,以便當我撥打data.duration
時,我得到2 days 04:00:00
?
注意持續時間使用計算:
data_frame['duration'] = data_frame['finish'] - data_frame['start']
也許轉換週期與STR(字符串在JavaScript中,簡單的方法,閱讀和達到的concensus幾年前在http://stackoverflow.com/questions/538666/python-format-timedelta-to-string。 – 2015-08-28 04:49:38