我使用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