@author jackzhenguo
@desc
@tag
@version
@date 2020/03/25
split 是更加高效的实现,同样需要先转化为 str 类型:
df['a'] = df['a'].astype(str)
df['b'] = df['b'].astype(str)
其次 split:
df['asplit'] = df['a'].str.split(':')
df['bsplit'] = df['b'].str.split(':')
使用 apply 操作每个元素,转化为分钟数:
df['amins'] = df['asplit'].apply(lambda x: int(x[0])*60 + int(x[1]))
df['bmins'] = df['bsplit'].apply(lambda x: int(x[0])*60 + int(x[1]))