如何计算自给定日期以来经过的分钟数

How to calculate minutes passed since given date

我有一个数据框,其中有一列名为 Created_Timestamp。我想看看自给定日期以来经过了多少分钟。我想知道 Created_Timestamp.

列中的停留时间(以分钟为单位)
 Created_Timestamp          Dwell Time
 2022-04-25 00:33:33.482      842 min 
 2022-04-25 08:30:52.904      364 min 
 2022-04-25 12:11:04.624      144 min

停留时间将从当前时间算起。

curtime = dt.now()
df['Dwell Time'] = curtime - df['Created_Timestamp']

这没有按我的预期工作。我怎样才能正确地做到这一点?

import pandas as pd
from datetime import datetime

curtime = datetime.now()

qqq = pd.to_datetime(df['Created_Timestamp'])
aaa = pd.to_datetime(curtime)
ttt = (aaa - qqq).dt.total_seconds()/60
df['Dwell Time'] = ttt

输出

         Created_Timestamp  Dwell  Time   Dwell Time
0  2022-04-25 00:33:33.482    842  min   1463.694005
1  2022-04-25 08:30:52.904    364  min    986.370305
2  2022-04-25 12:11:04.624    144   min   766.174972