Exemple #1
0
def getValues(data):
    values = {}
    i = 6
    while (i < len(data[0])):
        values[data[0][i]] = {}
        values[data[0][i]]['houses'] = []
        values[data[0][i]]['notes'] = []
        values[data[0][i]]['max'] = None
        values[data[0][i]]['min'] = None
        j = 1
        while (j < len(data)):
            values[data[0][i]]['houses'].append(data[j][1])
            if (check.isFloat(data[j][i])):
                value = float(data[j][i])
                values[data[0][i]]['notes'].append(value)
                if (values[data[0][i]]['max'] is None
                        or value > values[data[0][i]]['max']):
                    values[data[0][i]]['max'] = value
                if (values[data[0][i]]['min'] is None
                        or value < values[data[0][i]]['min']):
                    values[data[0][i]]['min'] = value
            else:
                values[data[0][i]]['notes'].append(None)
            j += 1
        i += 1
    for key in values:
        values[key] = scale(values[key])
    return values
Exemple #2
0
def getValues(data):
    values = {}
    i = 6
    while (i < len(data[0])):
        values[data[0][i]] = {}
        values[data[0][i]]['Gryffindor'] = []
        values[data[0][i]]['Ravenclaw'] = []
        values[data[0][i]]['Hufflepuff'] = []
        values[data[0][i]]['Slytherin'] = []
        values[data[0][i]]['max'] = None
        values[data[0][i]]['min'] = None
        j = 1
        while (j < len(data)):
            if (data[j][1] in values[data[0][i]]
                    and check.isFloat(data[j][i])):
                value = float(data[j][i])
                values[data[0][i]][data[j][1]].append(value)
                if (values[data[0][i]]['max'] is None
                        or value > values[data[0][i]]['max']):
                    values[data[0][i]]['max'] = value
                if (values[data[0][i]]['min'] is None
                        or value < values[data[0][i]]['min']):
                    values[data[0][i]]['min'] = value
            j += 1
        i += 1
    for key in values:
        values[key] = scale(values[key])
    return values
Exemple #3
0
def getSomme(data, n):
    x = 0
    i = 1
    while (i < len(data)):
        if (check.isFloat(data[i][n])):
            x += float(data[i][n])
        i += 1
    return x
Exemple #4
0
def getCount(data, n):
    x = 0
    i = 1
    while (i < len(data)):
        if (check.isFloat(data[i][n])):
            x += 1
        i += 1
    return x
Exemple #5
0
def getMax(data, n):
    x = None
    i = 1
    while (i < len(data)):
        if (check.isFloat(data[i][n])
                and (x is None or x < float(data[i][n]))):
            x = float(data[i][n])
        i += 1
    return x
Exemple #6
0
def getStd(data, n, mean):
    x = 0
    j = 0
    i = 1
    while (i < len(data)):
        if (check.isFloat(data[i][n])):
            x += math.pow(float(data[i][n]) - mean, 2)
            j += 1
        i += 1
    x /= j
    return math.sqrt(x)
Exemple #7
0
def getEcarts(data, n):
    valid = []
    i = 1
    while (i < len(data)):
        if (check.isFloat(data[i][n])):
            valid.append(float(data[i][n]))
        i += 1
    i = 0
    while (i < len(valid)):
        j = i + 1
        while (j < len(valid)):
            if (valid[j] < valid[i]):
                tmp = valid[j]
                valid[j] = valid[i]
                valid[i] = tmp
            j += 1
        i += 1
    first = int(math.ceil(len(valid) / 4))
    second = int(math.ceil(len(valid) / 2))
    third = int(len(valid) - first)
    return valid[first], valid[second], valid[third]