Deep Agents
Data Analysis Agent with Deep Agents
Build an AI data analysis agent that processes datasets, runs Python computations, generates charts, and produces insights — powered by Deep Agents.
data analysisPythonchartsanalytics
Working Code
from deepagents import create_deep_agentfrom langchain_core.tools import tool
@tooldef execute_python(code: str) -> str: """Execute Python code for data analysis. pandas and matplotlib are available.""" import subprocess result = subprocess.run( ["python", "-c", code], capture_output=True, text=True, timeout=30, ) return result.stdout or f"Error: {result.stderr}"
@tooldef read_csv_info(path: str) -> str: """Get info about a CSV file (columns, types, shape).""" import pandas as pd df = pd.read_csv(path) return f"Shape: {df.shape}\nColumns: {list(df.columns)}\nTypes:\n{df.dtypes}"
agent = create_deep_agent( model="anthropic:claude-sonnet-4-5-20250929", tools=[execute_python, read_csv_info], system_prompt="You are a data analyst. Explore datasets using read_csv_info, then use execute_python to run analysis code. Present findings clearly with numbers.",)
result = agent.invoke({ "messages": [("user", "Analyze sales_data.csv and find the top performing products by revenue")]})print(result["messages"][-1].content)Step by Step
1
Install dependencies
Install Deep Agents and the required tools for this use case.
2
Define your tools
Create the domain-specific tool functions your agent will use to interact with external services.
3
Create the agent and run
Initialize the Deep Agents agent with your tools, set the system prompt, and execute a query.
Build with other frameworks
Ready to build with Deep Agents?
Generate a production-ready project with Deep Agents pre-configured — FastAPI + Next.js, auth, streaming, and more.
Get StartedReady to build your first production AI agent?
Open-source tools, battle-tested patterns, zero boilerplate. Configure your stack and ship in minutes — not months.