create_csv_agent#
- langchain_experimental.agents.agent_toolkits.csv.base.create_csv_agent(llm: LanguageModelLike, path: str | IOBase | List[str | IOBase], pandas_kwargs: dict | None = None, **kwargs: Any) AgentExecutor [source]#
Create pandas dataframe agent by loading csv to a dataframe.
- Parameters:
llm (LanguageModelLike) – Language model to use for the agent.
path (Union[str, IOBase, List[Union[str, IOBase]]]) – A string path, file-like object or a list of string paths/file-like objects that can be read in as pandas DataFrames with pd.read_csv().
pandas_kwargs (Optional[dict]) – Named arguments to pass to pd.read_csv().
kwargs (Any) – Additional kwargs to pass to langchain_experimental.agents.agent_toolkits.pandas.base.create_pandas_dataframe_agent().
- Returns:
An AgentExecutor with the specified agent_type agent and access to a PythonAstREPLTool with the loaded DataFrame(s) and any user-provided extra_tools.
- Return type:
Example
from langchain_openai import ChatOpenAI from langchain_experimental.agents import create_csv_agent llm = ChatOpenAI(model="gpt-3.5-turbo", temperature=0) agent_executor = create_pandas_dataframe_agent( llm, "titanic.csv", agent_type="openai-tools", verbose=True )