Pandas groupby: Count the number of occurences within a time range for each group,df['yes'] = df['WIN'].map(lambda x: 1 if x == 'Yes' else np.nan)