【发布时间】:2016-05-21 12:40:03
【问题描述】:
我有一个看起来像这样的 pandas sim_df:
现在,我想添加另一列“日期”,即对应于“现在”加上“cum_days”(增量时间)的日期。
start = dt.datetime.now()
sim_df['date'] = start + dt.timedelta(sim_df['cum_days'])
但看起来 deltatime 不使用系列,而是使用固定标量。
TypeError: unsupported type for timedelta days component: Series
有没有办法在向量化操作中解决这个问题,而无需遍历 sim_df 的每一行?
【问题讨论】:
-
cum_days 是什么类型?浮动?