def project_deficit_stats_annual_pct_csv(request, project_id):
    """
    Stream a CSV with the annual volume deficit stats.
    """
    return __dataframe_annual_csv_helper(
        request, project_id,
        lambda d, g, t: analysis.annual_volume_deficit_pct(
            d, g, t, CFS_TO_AFD), "%")
示例#2
0
 def get_data(self, request, scenario_id):
     scenario = get_object_or_404(Scenario, pk=scenario_id)
     data = analysis.annual_volume_deficit_pct(
         scenario.get_data(),
         scenario.get_gap_attribute_name(),
         scenario.get_target_attribute_name(),
         analysis.CFS_TO_AFD
     )
     return data.reset_index()
def project_deficit_stats_pct_csv(request, project_id):
    project = get_object_or_404(Project, pk=project_id)
    monthly_result = __get_deficit_stats_comparison(
        project, lambda d, g, t: analysis.monthly_volume_deficit_pct(
            d, g, t, CFS_TO_AFD).mean().abs(), "%")
    annual_result = __get_deficit_stats_comparison(
        project, lambda d, g, t: analysis.annual_volume_deficit_pct(
            d, g, t, CFS_TO_AFD), "%").mean().abs()
    annual_result.name = "Annual Average"
    response = HttpResponse(content_type="text/csv")
    result = pd.concat(
        [monthly_result, annual_result.to_frame().transpose()], axis=0)
    result.to_csv(response)
    return response
示例#4
0
def project_deficit_stats_pct_csv(request, project_id):
    project = get_object_or_404(Project, pk=project_id)
    monthly_result = __get_deficit_stats_comparison(
        project,
        lambda d, g, t: analysis.monthly_volume_deficit_pct(d, g, t, CFS_TO_AFD).mean().abs(),
        "%")
    annual_result = __get_deficit_stats_comparison(
        project,
        lambda d, g, t: analysis.annual_volume_deficit_pct(d, g, t, CFS_TO_AFD),
        "%").mean().abs()
    annual_result.name = "Annual Average"
    response = HttpResponse(content_type="text/csv")
    result = pd.concat([monthly_result, annual_result.to_frame().transpose()], axis=0)
    result.to_csv(response)
    return response
示例#5
0
def project_deficit_stats_annual_pct_csv(request, project_id):
    """
    Stream a CSV with the annual volume deficit stats.
    """
    return __dataframe_annual_csv_helper(request, project_id,
        lambda d, g, t: analysis.annual_volume_deficit_pct(d, g, t, CFS_TO_AFD), "%")