我有一个Pandas DataFrame,如下所示
ReviewID ID Type TimeReviewed
205 76032930 51936827 ReportID 2015-01-15 00:05:27.513000
232 76032930 51936854 ReportID 2015-01-15 00:06:46.703000
233 76032930 51936855 ReportID 2015-01-15 00:06:56.707000
413 76032930 51937035 ReportID 2015-01-15 00:14:24.957000
565 76032930 51937188 ReportID 2015-01-15 00:23:07.220000
>>> type(df)
<class 'pandas.core.frame.DataFrame'>
Run Code Online (Sandbox Code Playgroud)
TimeReviewed是一个系列类型
>>> type(df.TimeReviewed)
<class 'pandas.core.series.Series'>
Run Code Online (Sandbox Code Playgroud)
我在下面试过,但它仍然没有改变系列类型
import pandas as pd
review = pd.to_datetime(pd.Series(df.TimeReviewed))
>>> type(review)
<class 'pandas.core.series.Series'>
Run Code Online (Sandbox Code Playgroud)
如何将df.TimeReviewed更改为DateTime类型并分别提取年,月,日,小时,分钟?我是python的新手,谢谢你的帮助.
我在python中有这个Pandas Dataframe,我想知道两行之间的时差,下一行减去前一行,我该如何处理?
已审核[x] - 已审核[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
Run Code Online (Sandbox Code Playgroud)