run-llama/llama_index · error · ImportError

Pandas is required to get results dataframes. Please install

Error message

Pandas is required to get results dataframes. Please install it with `pip install pandas`.

What it means

Raised by get_results_df in eval_utils when pandas is not installed in the environment. The function needs pandas only to build the summary DataFrame of mean metric scores, so the core evaluation works without it — only the dataframe aggregation step fails.

Source

Thrown at llama-index-core/llama_index/core/evaluation/eval_utils.py:62

    names: List[str],
    metric_keys: List[str],
) -> Any:
    """
    Get results df.

    Args:
        eval_results_list (List[Dict[str, List[EvaluationResult]]]):
            List of evaluation results.
        names (List[str]):
            Names of the evaluation results.
        metric_keys (List[str]):
            List of metric keys to get.

    """
    try:
        import pandas as pd
    except ImportError:
        raise ImportError(
            "Pandas is required to get results dataframes. Please install it with `pip install pandas`."
        )

    metric_dict = defaultdict(list)
    metric_dict["names"] = names
    for metric_key in metric_keys:
        for eval_results in eval_results_list:
            mean_score = np.array(
                [r.score or 0.0 for r in eval_results[metric_key]]
            ).mean()
            metric_dict[metric_key].append(mean_score)
    return pd.DataFrame(metric_dict)


def default_parser(eval_response: str) -> Tuple[Optional[float], Optional[str]]:
    """
    Default parser function for evaluation response.

View on GitHub (pinned to afd0fef371)

Solutions

  1. Install pandas: pip install pandas (or add it to your project dependencies).
  2. If you cannot install it, compute the means yourself from eval_results (score fields) without get_results_df.
  3. Verify the install with python -c "import pandas" to catch broken installs.

Example fix

# before (ImportError at get_results_df)
df = get_results_df(results, names, metric_keys)

# after
# shell: pip install pandas
df = get_results_df(results, names, metric_keys)
Defensive patterns

Strategy: try-catch

Validate before calling

try:
    import pandas  # noqa
    HAS_PANDAS = True
except ImportError:
    HAS_PANDAS = False

if not HAS_PANDAS:
    # compute means manually or skip get_results_df
    ...

Try / catch

try:
    df = get_results_df(results, names, metric_keys)
except ImportError:
    df = None  # or aggregate scores with statistics.mean yourself

Prevention

When it happens

Trigger: Calling get_results_df(eval_results_list, names, metric_keys) in an environment where the pandas import fails (not installed, or a broken install).

Common situations: Running llama-index-core in a slim environment/容器 that excluded optional extras; CI images trimmed for size; installing llama-index-core alone, since pandas is not a hard dependency; a partially broken pandas install (wrong ABI/wheel).

Related errors


AI-assisted analysis of run-llama/llama_index@afd0fef371 (2026-08-15). Data as JSON: /api/errors/c019f27ca9982130. Report an issue: GitHub.