使用python pandas 将hh:mm:ss转换为分钟 [英] Convert hh:mm:ss to minutes using python pandas
本文介绍了使用python pandas 将hh:mm:ss转换为分钟的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有一个数据框列data['time taken']
;
02:08:00
02:05:00
02:55:00
03:42:00
01:12:00
01:46:00
03:22:00
03:36:00
如何获得如下分钟形式的输出?
How do I get the output in the form of minutes like below?
128
125
175
222
72
106
202
216
推荐答案
您可以尝试将其转换为DatetimeIndex
You could try to convert it to DatetimeIndex
In [58]: time = pd.DatetimeIndex(df['time taken'])
In [59]: time.hour * 60 + time.minute
Out[59]: array([128, 125, 175, 222, 72, 106, 202, 216], dtype=int32)
这篇关于使用python pandas 将hh:mm:ss转换为分钟的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文