【发布时间】:2015-03-23 02:17:10
【问题描述】:
我在python中有这个Pandas Dataframe,我想知道两行之间的时间差,下一行减去上一行,我应该如何处理?
Reviewed[x] - Reviewed[x-1] x 是该行所在位置的编号
ReporterID ID Type Reviewed
0 27545252 51884791 ReportID 2015-01-14 00:00:42.640000
1 29044639 51884792 ReportID 2015-01-14 00:00:02.767000
2 29044639 51884793 ReportID 2015-01-14 00:00:28.173000
3 29044639 51884794 ReportID 2015-01-14 00:00:46.300000
4 27545252 51884796 ReportID 2015-01-14 00:01:54.293000
5 29044639 51884797 ReportID 2015-01-14 00:01:17.400000
6 29044639 51884798 ReportID 2015-01-14 00:01:57.600000
【问题讨论】:
-
df.Reviewed.diff() 可以工作。来源:pandas.pydata.org/pandas-docs/stable/reference/api/…
标签: python datetime numpy pandas dataframe