run-llama/llama_index · error · ImportError

pandas is required for this function. Please install it with

Error message

pandas is required for this function. Please install it with `pip install pandas`.

What it means

Error "pandas is required for this function. Please install it with `pip install pandas`." thrown in run-llama/llama_index.

Source

Thrown at llama-index-core/llama_index/core/postprocessor/node_recency.py:65

    """

    top_k: int = 1
    date_key: str = "date"

    @classmethod
    def class_name(cls) -> str:
        return "FixedRecencyPostprocessor"

    def _postprocess_nodes(
        self,
        nodes: List[NodeWithScore],
        query_bundle: Optional[QueryBundle] = None,
    ) -> List[NodeWithScore]:
        """Postprocess nodes."""
        try:
            import pandas as pd
        except ImportError:
            raise ImportError(
                "pandas is required for this function. Please install it with `pip install pandas`."
            )

        if query_bundle is None:
            raise ValueError("Missing query bundle in extra info.")

        # sort nodes by date
        node_dates = pd.to_datetime(
            [node.node.metadata[self.date_key] for node in nodes]
        )
        sorted_node_idxs = np.flip(node_dates.argsort())
        sorted_nodes = [nodes[idx] for idx in sorted_node_idxs]

        return sorted_nodes[: self.top_k]


DEFAULT_QUERY_EMBEDDING_TMPL = (
    "The current document is provided.\n"

View on GitHub (pinned to afd0fef371)

Solutions

  1. Install pandas: `pip install pandas`.

When it happens

Trigger: Thrown at llama-index-core/llama_index/core/postprocessor/node_recency.py:65 when the library encounters an invalid state.

Common situations: See trigger scenarios.


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