def expand_groundedness_df(df: pd.DataFrame) -> pd.DataFrame:
    """
    Expand the groundedness DataFrame by splitting the reasons column into separate rows and columns.

    Args:
        df (pd.DataFrame): The groundedness DataFrame.

    Returns:
        pd.DataFrame: The expanded DataFrame.
    """
    # Split the reasons value into separate rows and columns
    if "explanation" in df.columns:
        reasons = df["explanation"].iloc[0]
    elif "reasons" in df.columns:
        reasons = df["reasons"].iloc[0]
    else:
        raise ValueError(
            "Missing 'explanation' or 'reasons' column from feedbacks."
        )
    # Split the reasons into separate statements
    statements = reasons.split("STATEMENT")
    data = []
    # Each reason has three components: statement, supporting evidence, and score
    # Parse each reason into these components and add them to the data list
    for statement in statements[1:]:
        try:
            criteria = statement.split("Criteria: ")[1].split(
                "Supporting Evidence: "
            )[0]
            supporting_evidence = statement.split("Supporting Evidence: ")[
                1
            ].split("Score: ")[0]
            score_pattern = re.compile(r"([0-9]*\.?[0-9]+)(?=\D*$)")
            score_split = statement.split("Score: ")[1]
            score_match = score_pattern.search(score_split)
            if score_match:
                score = float(score_match.group(1))
            else:
                score = None
        except IndexError:
            # Handle cases where the expected substrings are not found
            criteria = None
            supporting_evidence = None
            score = None
        data.append({
            "Statement": criteria,
            "Supporting Evidence from Source": supporting_evidence,
            "Groundedness Score": score,
        })
    reasons_df = pd.DataFrame(data)

    reasons_df.rename(columns={"Groundedness Score": "score"}, inplace=True)

    # Return only the expanded reasons DataFrame
    return reasons_df.reset_index(drop=True)

    Expand the groundedness DataFrame by splitting the reasons column into separate rows and columns.

    Args:
        df (pd.DataFrame): The groundedness DataFrame.

    Returns:
        pd.DataFrame: The expanded DataFrame.
    
src/dashboard/trulens/dashboard/display.py