Skip to main content
This notebook shows how to use agents to interact with a Pandas DataFrame. It is mostly optimized for question answering. NOTE: this agent calls the Python agent under the hood, which executes LLM generated Python code - this can be bad if the LLM generated Python code is harmful. Use cautiously. NOTE: Since langchain migrated to v0.3 you should upgrade langchain_openai and langchain. This would avoid import errors. pip install -U langchain_openai pip install -U langchain
The langchain-experimental package is no longer maintained. Examples that import from langchain_experimental may be outdated or broken. Use with caution.

Using ZERO_SHOT_REACT_DESCRIPTION

This shows how to initialize the agent using the ZERO_SHOT_REACT_DESCRIPTION agent type.

Using OpenAI functions

This shows how to initialize the agent using the OPENAI_FUNCTIONS agent type. Note that this is an alternative to the above.

Multi DataFrame example

This next part shows how the agent can interact with multiple dataframes passed in as a list.