df = pd.DataFrame({'user_id': [1, 1, 1, 1, 2, 2, 2, 2], 'start_timestamp':
    [1, 3, 20, 26, 1, 5, 40, 42], 'end_timestamp': [2, 4, 25, 27, 2, 10, 41,
    50]}, columns=['user_id', 'start_timestamp', 'end_timestamp'])
Is there another way to add a column to a groupby when using pandas?