Pandas Query Engine

Default query for GPTPandasIndex.

class llama_index.indices.struct_store.pandas_query.GPTNLPandasQueryEngine(index: GPTPandasIndex, instruction_str: Optional[str] = None, output_processor: Optional[Callable] = None, pandas_prompt: Optional[PandasPrompt] = None, output_kwargs: Optional[dict] = None, head: int = 5, verbose: bool = False, **kwargs: Any)

GPT Pandas query.

Convert natural language to Pandas python code.

  • df (pd.DataFrame) – Pandas dataframe to use.

  • instruction_str (Optional[str]) – Instruction string to use.

  • output_processor (Optional[Callable[[str], str]]) – Output processor. A callable that takes in the output string, pandas DataFrame, and any output kwargs and returns a string.

  • pandas_prompt (Optional[PandasPrompt]) – Pandas prompt to use.

  • head (int) – Number of rows to show in the table context.

llama_index.indices.struct_store.pandas_query.default_output_processor(output: str, df: DataFrame, **output_kwargs: Any) str

Process outputs in a default manner.