hana_ai.smart_dataframe
hana.ai smart_dataframe is a dataframe agent to perform HANA dataframe operations via natural language.
Smart DataFrame.
The following class is available:
:class SmartDataFrame
- class hana_ai.smart_dataframe.SmartDataFrame(dataframe: DataFrame)
Smart DataFrame.
- Parameters:
- dataframeDataFrame
Dataframe.
Examples
>>> from hana_ai.smart_dataframe import SmartDataFrame
>>> sdf = SmartDataFrame(dataframe=hana_df) >>> sdf.configure(llm=llm, verbose=True) >>> sdf.ask(question="Show the samples of the dataset") >>> new_sdf = sdf.transform(question="Get last two rows")
- configure(llm: BaseLLM, tools: List[BaseTool] = None, verbose: bool = False, **kwargs)
Configure the Smart DataFrame.
- Parameters:
- llmBaseLLM
LLM.
- toolsList of BaseTool, optional
The dataframe tools to use.
Defaults to df_tools.
- ask(question: str)
Ask a question.
- Parameters:
- questionstr
Question.
- transform(question: str, output_key='output')
Transform the dataframe.
The model output must be a single read-only SELECT/WITH statement. Comments, unsafe statements and embedded semicolons are rejected; one trailing terminator is removed before passing SQL to hana-ml. These checks do not restrict the permissions of tools used by ask().
- Parameters:
- questionstr
Question.
- output_keystr, optional
Reserved for compatibility; the executor's 'output' key is used.