def get_all_stats(xform, field=None): data = {} for field_name in [field] if field else get_numeric_fields(xform): _min, _max, _range = get_min_max_range_for_field(field_name, xform) mode = get_mode_for_field(field_name, xform) mean = get_mean_for_field(field_name, xform) median = get_median_for_field(field_name, xform) data[field_name] = { 'mean': round(mean, DECIMAL_PRECISION), 'median': median, 'mode': round(mode, DECIMAL_PRECISION), 'max': _max, 'min': _min, 'range': _range } return data
def get_mode_for_numeric_fields_in_form(xform, field=None): data = {} for field_name in [field] if field else get_numeric_fields(xform): mode = get_mode_for_field(field_name, xform) data.update({field_name: round(mode, DECIMAL_PRECISION)}) return data
def get_min_max_range(xform, field=None): data = {} for field_name in [field] if field else get_numeric_fields(xform): _min, _max, _range = get_min_max_range_for_field(field_name, xform) data[field_name] = {'max': _max, 'min': _min, 'range': _range} return data
def get_median_for_numeric_fields_in_form(xform, field=None): data = {} for field_name in [field] if field else get_numeric_fields(xform): median = get_median_for_field(field_name, xform) data.update({field_name: median}) return data