

def format_time_and_value_to_segment_list(time_and_value_list, segments_count, start_timestamp, end_timestamp, average=False):
    "\n    Format time_and_value_list to time segments\n\n    Parameters\n    ----------\n    time_and_value_list: list of tuples\n        Have to be sorted by time\n        Example: [(time, value), (time, value) ...]\n    segments_count: integer\n        How many segments will be in result\n    Returns\n    -------\n    List of dictionaries\n        Example:\n        [{'from': time1, 'to': time2, 'value': sum_of_values_from_time1_to_time2}, ...]\n    "
    segment_list = []
    time_step = ((end_timestamp - start_timestamp) / segments_count)
    for i in range(segments_count):
        segment_start_timestamp = (start_timestamp + (time_step * i))
        segment_end_timestamp = (start_timestamp + time_step)
        value_list = [value for (time, value) in time_and_value_list if ((time >= segment_start_timestamp) and (time < segment_end_timestamp))]
        segment_value = sum(value_list)
        if (average and (len(value_list) != 0)):
            segment_value /= len(value_list)
        segment_list.append({
            'from': segment_start_timestamp,
            'to': segment_end_timestamp,
            'value': segment_value,
        })
    return segment_list

dataset/ETHPy150Open opennode/nodeconductor/nodeconductor/core/utils.py format_time_and_value_to_segment_list/VarMisuse@64/281 `segment_start_timestamp`->`start_timestamp`