【发布时间】:2013-02-03 14:58:02
【问题描述】:
我有一个这样的时间戳列。
In [493]: df_data['last_seen'][:5]
Out[493]:
1 1838-10-31 01:36:32.493180416
2 1826-08-10 09:38:02.493180416
3 1839-05-04 21:14:42.493180416
4 1831-06-11 17:44:24.493180416
5 1820-01-26 10:32:07.493180416
Name: last_seen
我想要自每行的最近时间戳以来经过的小时数。所以我写了
df['last_seen'] = df['last_seen'] - df['last_seen'].max()
这会引发错误。
AttributeError: 'Timestamp' object has no attribute 'dtype'
请注意,当我要求时:
>>> type(df['last_seen'])
>>> pandas.core.series.Series
>>> type(df_data['last_seen'][1])
>>> pandas.tslib.Timestamp
【问题讨论】:
-
这应该适用于 0.11-dev(当前主),不确定以前的版本。你在什么版本?你能显示 df['last_seen'] 的 dtype 吗?