Parsing Analysis Results


When an analysis is executed, BrandIndex takes the analysis definition's queries and runs each independently. The results that are returned provide complex data for each of the executed queries. Each result is an AnalysisQueryResult (the full definition can be found on the BrandIndex API Swagger UI). The data attribute of each query provides not only the values but also instructions on how to parse through them. The important parts of the data attribute structure are:

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
{
    "coordinates": {
        # dates are in YYYY-MM-DD format
        "dates": List[str],
        # Metric can be found in brandindex.models
        "metrics": List[Metric],
        # ScoreType is found in brandindex.models
        "perspective": List[ScoreType],
    },
    "values": List[List[List[float]]]
}

The values attribute is a 3-level list structure that can be described using the information in the coordinates attribute.

  • Level 1
    • Item Type: List[List[float]]
    • Aligns with: coordinates['metric']
  • Level 2
    • Item Type: List[float]
    • Aligns with: coordinates['date']
  • Level 3
    • Item Type: float
    • Aligns with: coordinates['perspective']

To get the values for each score type for a metric on a day is just iterating over the list.