I have a DataFrame with two columns
userID duration
0 DSm7ysk 03:08:49
1 no51CdJ 00:35:50
2 ...
with 'duration' having type timedelta. I have tried using
bins = [dt.timedelta(minutes = 0), dt.timedelta(minutes =
5),dt.timedelta(minutes = 10),dt.timedelta(minutes =
20),dt.timedelta(minutes = 30), dt.timedelta(hours = 4)]
labels = ['0-5min','5-10min','10-20min','20-30min','30min+']
df['bins'] = pd.cut(df['duration'], bins, labels = labels)
However, the binned data doesn't use the specified bins, but created on for each duration in the frame.
What is the simplest way to bin timedelta objects into irregular bins? Or am I just missing something obvious here?