I am new in python and pandas and even though I researched a lot about intervals, I couldnt find any solution for my problem, I hope someone can help
Here is a sample of my DF
df = pd.DataFrame(
data=[['Mel Gibson', 'German', '2021-9-23 14:22:38', 301 ],
['Jim Carrey', 'German', '2021-9-23 14:27:39', 1041 ],
['Mel Gibson', 'German','2021-9-24 13:33:22',12]],
columns=['specialist', 'Language', 'Interval Start', 'status_duration']
)
df['Interval Start'] = pd.to_datetime(df['Interval Start'])
What I want to do is transform status duration to 15 minute intervals and group them per specialist and per day.
My desired output should be like below:
df = pd.DataFrame(
data=[['Mel Gibson', 'German', '2021-9-23 14:15:00', 301 ],
['Jim Carrey', 'German', '2021-9-23 14:15:00', 141 ],
['Jim Carrey', 'German', '2021-9-23 14:30:00', 900 ],
['Mel Gibson', 'German','2021-9-24 13:30:00',12]],
columns=['specialist', 'Language', 'Interval Start', 'status_duration']
)
So basically I need to split the seconds in status duration in 15 minute intervals until there is no remaining duration.
Edit:
My original data is like this:
df = pd.DataFrame(
data=[['Mel Gibson', 'German', '2021-9-23 14:22:38', 301 ],
['Mel Gibson', 'German', '2021-9-23 14:27:40', 4678 ],
['Mel Gibson', 'German','2021-9-24 13:33:22',12]],
columns=['specialist', 'Language', 'Interval Start', 'status_duration']
)
df['Interval Start'] = pd.to_datetime(df['Interval Start'])
The code from Henry gives me output for only the first row, second row is skipped.
Also lets say if a call has started at 10:35:00, this interval's(10:30-10:45) can not exceed 600 seconds as there are only 10 minutes left from the start time.