Просто рассчитайте разницу для каждой строки и затем отфильтруйте, если хотите ... это предполагает, что ваш кадр отсортирован надлежащим образом
# create groupby object
g = df.groupby('Event')
# calculate the difference for each group
df['diff'] = g['Transition Date'].diff(periods=1)
# create a mask to filter based on your conditions
mask = ((g['To'].shift(0) == 'In Progress') & (g['From'].shift(-1) == 'In Progress')) |\
((g['From'].shift(0) == 'In Progress') & (g['To'].shift(1) == 'In Progress'))
print(df[mask])
Event Transition Date From To \
0 ESS-123 2018-12-28 10:27:35.913 Planning In Progress
1 ESS-123 2019-04-20 10:51:07.857 In Progress Deferred
2 HTO-254 2019-04-04 15:19:06.013 Planning In Progress
3 HTO-254 2019-05-05 10:35:03.083 In Progress Not in work
5 AEW-8465 2018-10-01 09:40:34.070 Work Planned In Progress
6 AEW-8465 2018-10-01 10:30:07.993 In Progress Suspended
7 AEW-8465 2018-10-25 12:22:13.203 Drafted In Progress
8 AEW-8465 2019-02-05 15:58:13.900 In Progress Suspended
diff
0 NaT
1 113 days 00:23:31.944000
2 NaT
3 30 days 19:15:57.070000
5 NaT
6 0 days 00:49:33.923000
7 24 days 01:52:05.210000
8 103 days 03:36:00.697000
или если вы хотите, чтобы общее время каждого события было потрачено
df[mask].groupby('Event')['diff'].sum()
Event
AEW-8465 127 days 06:17:39.830000
ESS-123 113 days 00:23:31.944000
HTO-254 30 days 19:15:57.070000
Name: diff, dtype: timedelta64[ns]