我有一个以 unix 时间为开始日期的 pandas 系列时间样本。每个时间样本为 x * 1 / 512,因此时间戳 0 = 0,时间戳 2 = 1 / 512 或 0.00195,时间戳 3 = 2 / 512 或 0.0039。我需要将开始日期(偏移量)添加到所有值并将结果转换为本地时间(PST)。我有以下times = np.arange(0, 3600, 1/512)tz = 'US/Pacific'offset = 1569603352 # 2019-09-27 09:57 (or something similar)srs = pd.Series(times)srs.apply(lambda t: pd.to_datetime(offset + t, unit='s', utc=True) \ .tz_convert(tz))有什么方法可以加快速度吗?我有一堆强大的 GPU 和大约 50 个线程,因此可以使用多线程或处理。
1 回答

牛魔王的故事
TA贡献1830条经验 获得超3个赞
我将通过删除加快速度apply
pd.to_datetime(offset + srs, unit='s', utc=True).dt.tz_convert(tz)
添加回答
举报
0/150
提交
取消