def generate_service_id(stop_times):
    """Generate service_id into stop_times DataFrame"""
    stop_times['service_id'] = None
    calendar_info = stop_times.drop_duplicates(subset=['vehicle_journey_id'])
    calendar_groups = calendar_info.groupby('weekdays')
    for weekday, cgroup in calendar_groups:
        vehicle_journey_ids = cgroup['vehicle_journey_id'].to_list()
        service_ref = cgroup['service_ref'].unique()[0]
        daygroup = cgroup['weekdays'].unique()[0]
        start_d = cgroup['start_date'].unique()[0]
        end_d = cgroup['end_date'].unique()[0]
        service_id = '%s_%s_%s_%s' % (service_ref, start_d, end_d, daygroup)
        stop_times.loc[stop_times['vehicle_journey_id'].isin(
            vehicle_journey_ids), 'service_id'] = service_id
    return stop_times
