def group_singles2array(input, **params):
    """
    Creates array of strings or ints from objects' fields
    :param input: list of objects
    :param params:
    :return: list
    """
    PARAM_FIELD_KEY = 'field.key'
    PARAM_FIELD_ARRAY = 'field.array'
    PARAM_FIELD_SINGLE = 'field.single'

    field_key = params.get(PARAM_FIELD_KEY) if PARAM_FIELD_KEY in params else None
    field_array = params.get(PARAM_FIELD_ARRAY)
    field_single = params.get(PARAM_FIELD_SINGLE)

    if not field_key:
        res = []
        for item in input:
            res.append(item[field_single])
        return {field_array: res}
    else:
        tdict = {}
        for row in input:
            if not row[field_key] in tdict:
                tdict.update({row[field_key]: [row[field_single]]})
            else:
                tdict[row[field_key]].append(row[field_single])
        res = []
        for key, value in tdict.items():
            res.append({field_key: key, field_array: value})
        return res
def group_singles2array ( input , ** params ) : PARAM_FIELD_KEY = 'field.key' PARAM_FIELD_ARRAY = 'field.array' PARAM_FIELD_SINGLE = 'field.single' field_key = params . get ( PARAM_FIELD_KEY ) if PARAM_FIELD_KEY in params else None field_array = params . get ( PARAM_FIELD_ARRAY ) field_single = params . get ( PARAM_FIELD_SINGLE ) if not field_key : res = [ ] for item in input : res . append ( item [ field_single ] ) return { field_array : res } else : tdict = { } for row in input : if not row [ field_key ] in tdict : tdict . update ( { row [ field_key ] : [ row [ field_single ] ] } ) else : tdict [ row [ field_key ] ] . append ( row [ field_single ] ) res = [ ] for key , value in tdict . items ( ) : res . append ( { field_key : key , field_array : value } ) return res
Creates array of strings or ints from objects' fields
    :param input: list of objects
    :param params:
    :return: list