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
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.Connect these docs programmatically to Claude, VSCode, and more via MCP for real-time answers.