【发布时间】:2019-03-22 12:57:16
【问题描述】:
我知道可以通过以下方式将单个日期时间观察转换为 Unix 时间戳:
import datetime as dt
int(dt.datetime.now().timestamp())
如何使用这样的系列进行转换:
import pandas as pd
x = dt.datetime.now()
y = x + dt.timedelta(seconds=300)
z = pd.Series([x, y])
z:
0 2019-03-22 13:53:42.671575
1 2019-03-22 13:58:42.671575
dtype: datetime64[ns]
【问题讨论】:
-
使用
print (z.astype(np.int64) // 10**9)
标签: python-3.x pandas time-series