Ejemplo n.º 1
0
def calculate_percents(data):
    calculated_data = [None]*len(data)
    total = maxarray.sum_total_columns(data, (1,))
    for idx, row in enumerate(data):
        result = row[1]*100 / float(total[0])
        result = maxpercent.get_percent_representation_two_decimals(result)
        new_row = [row[0], result, row[1]]
        calculated_data[idx] = new_row
    return calculated_data
Ejemplo n.º 2
0
def process_data(matrix):
    transformed_data = TransformedData()
    transform_matrix(matrix)
    transformed_data.matrix_months = matrix
    transformed_data.total_year = maxarray.sum_total_columns(matrix, range(1,12))
    transformed_data.quarter1_total = maxarray.sum_total_columns_from_rows(matrix, range(1,12), axis_rows=range(0,3))
    transformed_data.quarter2_total = maxarray.sum_total_columns_from_rows(matrix, range(1,12), axis_rows=range(3,6))
    transformed_data.quarter3_total = maxarray.sum_total_columns_from_rows(matrix, range(1,12), axis_rows=range(6,9))
    transformed_data.quarter4_total = maxarray.sum_total_columns_from_rows(matrix, range(1,12), axis_rows=range(9,12))
    return transformed_data
Ejemplo n.º 3
0
 def test_sum_columns(self):
     data = [['Jan',4,4,4],['Feb',2,-2,4]]
     result = maxarray.sum_total_columns(data, axis_columns=range(1,4))
     self.assertEquals([6, 2, 8], result)
     print result