擅长:python、mysql、java
<p>这是一种不合理的方法,主要的问题是缺少对<code>time</code>对象的矢量化支持,因此首先需要使用<code>combine</code>将<code>time</code>转换为<code>datetime</code>,然后应用偏移量并取回<code>time</code>组件:</p>
<pre><code>In [28]:
import datetime as dt
df['new_time'] = df['time'].apply(lambda x: (dt.datetime.combine(dt.datetime(1,1,1), x,) + dt.timedelta(hours=3,minutes=30)).time())
df
Out[28]:
time new_time
index
0 04:50:00 08:20:00
1 04:50:00 08:20:00
2 05:00:00 08:30:00
3 05:12:00 08:42:00
4 06:04:00 09:34:00
5 06:44:00 10:14:00
6 06:44:00 10:14:00
7 06:47:00 10:17:00
8 06:47:00 10:17:00
9 06:47:00 10:17:00
</code></pre>