I try to get a player's playing time from the time he is in play according to the actual playing time.
I start learning python by trying to reproduce an R code I made. In R i use foverlaps this way :
Data <- foverlaps(Data_players, Data_play, type = "any")
Data[, `:=`(from = if_else( i.Start < Start, Start, i.Start),
to = if_else( i.Stop > Stop, Stop, i.Stop) )][]
Data[, Time := as.numeric( to - from )]
Where Data_players and Data_play are composed of Start Time and End Time
In python I tried :
Data = pd.merge(Data_play, Data_player, on=['Start', 'Stop'])
But it returns nothing in the data frame.
For exemple I have this Data_play :
Name Start Stop
Play 1900-01-01 00:15:01.570000 1900-01-01 00:15:24.460000
Play 1900-01-01 00:15:56.240000 1900-01-01 00:16:04.330000
and this Data_player :
Name Start Stop
Player 1900-01-01 00:14:58.500000 1900-01-01 00:16:25.600000
and expected new column 'Time' like this :
Name Start Stop Time
Player ... ... 00:00:30