def get_district_subject_std_values(subject_name, table_code): wheres = [school_where, exam_where] if subject_name == "总分": stu_table = table_config.get_stu_sum_table(table_code) school_table = table_config.get_school_sum_table(table_code) else: stu_table = table_config.get_stu_dimen_table(table_code) school_table = table_config.get_school_dimen_table(table_code) subject_where.set_value(get_subject_id_by_name(subject_name)) wheres.append(subject_where) subject_total = report_config.get_total(subject_name) xresult = [] yresult = [] school_subject_num_cell = qa.Cell("num_nz", school_table, wheres) school_subject_num_row = qa.RowSeriesCell(school_subject_num_cell, school_ids) school_subject_avg_cell = qa.Cell("ROUND(avg / %d, 2)" % subject_total, school_table, wheres) school_subject_avg_row = qa.RowSeriesCell(school_subject_avg_cell, school_ids) stu_subject_sum_cell = qa.Cell("sum", stu_table, wheres) stu_subject_sum_row = qa.ColSeriesCell(stu_subject_sum_cell, school_ids) for value in stu_subject_sum_row.get_values(): yresult.append(round(np.std(value, ddof=1), 2)) xresult = school_subject_avg_row.get_values()[0] num = school_subject_num_row.get_values()[0] return xresult, yresult, num
def get_district_subject_distribution_values(subject_name, ids, table_code): distribution = report_config.get_distribution(subject_name) statistics_type = distribution[0] greater_where = qa.Where("sum", symbol=">") less_equal_where = qa.Where("sum", symbol="<=") basic_where = [exam_where] if subject_name == "总分": dimen_table = table_config.get_stu_sum_table(table_code) if statistics_type == report_config.COUNT: basic_where.append(qa.Where("count", value=distribution[2])) else: dimen_table = table_config.get_stu_dimen_table(table_code) subject_where.value = get_subject_id_by_name(subject_name) basic_where.append(subject_where) normal_cell = qa.Cell("COUNT(*)", dimen_table, [[greater_where, less_equal_where]] + basic_where) if statistics_type == report_config.ALL: greater_equal_where = qa.Where("sum", symbol=">=") extra_cell = qa.Cell("COUNT(*)", dimen_table, [[greater_equal_where, less_equal_where]] + basic_where) row1 = qa.RowSeriesCell(extra_cell, ids[0:1]) row2 = qa.RowSeriesCell(normal_cell, ids[1:]) return qa.DataRows.combine_col_rows(row1, row2) else: row = qa.RowSeriesCell(normal_cell, ids) return row.get_values()
def test2(): ids = [] names = [] start, end, step = [0, 150, 5] scopes = range(start, end, step) for index, scope in enumerate(scopes[0:-1]): ids.append([scope, scopes[index + 1]]) names.append("(%d, %d]" % (scope, scopes[index + 1])) if scopes[-1] < end: ids.append([scopes[-1], end]) names.append("(%d, %d]" % (scopes[-1], end)) names[0] = "[%d, %d]" % (scopes[0], scopes[1]) greater_equal_where = qa.Where("sum", symbol=">=") greater_where = qa.Where("sum", symbol=">") less_equal_where = qa.Where("sum", symbol="<=") cell1 = qa.Cell( "COUNT(*)", stu_dimen_table, [[greater_equal_where, less_equal_where], exam_where, subject_where]) cell2 = qa.Cell( "COUNT(*)", stu_dimen_table, [[greater_where, less_equal_where], exam_where, subject_where]) row1 = qa.RowSeriesCell(cell1, ids[0:1]) row2 = qa.RowSeriesCell(cell2, ids[1:]) table = qa.TableRows(["分数段", names], ['个数'], [row1, row2]) for table_row in table.get_values(): print(table_row)
def get_district_subject_std_values(subject_name, type_code, table_code): wheres = [school_where, exam_where] if subject_name == "总分": stu_table = table_config.get_stu_sum_table(table_code) school_table = table_config.get_school_table(type_code)[1] else: stu_table = table_config.get_stu_dimen_table(table_code) school_table = table_config.get_school_table(type_code)[0] subject_where.set_value(get_subject_id_by_name(subject_name)) wheres.append(subject_where) subject_total = report_config.get_total(subject_name) xresult = [] yresult = [] school_subject_num_cell = qa.Cell("num_nz", school_table, wheres) school_subject_num_row = qa.RowSeriesCell(school_subject_num_cell, school_ids) for school_id in school_ids: school_where.set_value(school_id) school_subject_avg_cell = qa.Cell("avg", school_table, wheres) stu_subject_sum_cell = qa.Cell("sum", stu_table, wheres) xresult.append( round(school_subject_avg_cell.get_value() / subject_total, 2)) yresult.append( round(np.std(stu_subject_sum_cell.get_row_values(), ddof=1), 2)) num = school_subject_num_row.get_values()[0] return xresult, yresult, num
def __init__(self, exam, gradation, where): self.exam = exam self.gradation = gradation self.where = where # self.exam = handler.Exam() # self.gradation = handler.Gradation() # self.where = handler.Where() self.cell_where = qa.CellWhere() self.cell_order = qa.CellOrder() self.cell = qa.Cell(where_list=self.cell_where) self.order_cell = qa.CellWithOrders(where_list=self.cell_where, order=self.cell_order) self.row_value = qa.RowSeriesCell() self.col_value = qa.ColSeriesCell()
def test3(): print(school_names) subject_total = 150 xresult = [] yresult = [] school_subject_num_cell = qa.Cell( "num_nz", "qa_school_dimen", [school_where, exam_where, subject_where]) school_subject_num_row = qa.RowSeriesCell(school_subject_num_cell, school_ids) for school_id in school_ids: school_subject_avg_cell = qa.Cell( "avg", "qa_school_dimen", [school_where, exam_where, subject_where]) school_where.value = school_id xresult.append(school_subject_avg_cell.get_value() / subject_total) stu_subject_sum_cell = qa.Cell( "sum", "qa_stu_dimen", [exam_where, school_where, subject_where]) yresult.append(np.std(stu_subject_sum_cell.get_row_values(), ddof=1)) print(xresult) print(yresult) print(school_subject_num_row.get_values()[0])
def get_value(self): return qa.RowSeriesCell(self.get_cell(), self.ids).get_values()
def get_row_value(cell, ids): return qa.RowSeriesCell(cell, ids).get_values()