feat(examples): add CSV data analysis agent example#1777
Open
Mohammad Mohtashim (keenborder786) wants to merge 2 commits intolangchain-ai:mainfrom
Open
feat(examples): add CSV data analysis agent example#1777Mohammad Mohtashim (keenborder786) wants to merge 2 commits intolangchain-ai:mainfrom
Mohammad Mohtashim (keenborder786) wants to merge 2 commits intolangchain-ai:mainfrom
Conversation
Contributor
Author
|
Hello Mason Daugherty (@mdrxy), I’ve added another example as requested in issue #951. |
Member
|
A couple things to align with the example contributing guidelines:
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Adds a new
data-analysis-agentexample that analyzes CSV files using pandasand matplotlib, producing structured reports with charts.
Use case as per in #951 to add more example
Why this example
The existing examples all use
FilesystemBackendand return free-text responses.This example fills two notable SDK gaps:
LocalShellBackend— first example to use shell execution via theexecutetool. The agent writes and runs self-contained Python scripts(pandas, matplotlib) to compute statistics and generate charts, which is a
fundamentally different interaction pattern from the file read/write workflows
in other examples.
Structured output (
ToolStrategy) — first example to useresponse_format.The agent returns a typed
DataReportPydantic model with findings, severitylevels, and recommendations instead of unstructured text. This makes the output
programmatically consumable.
It also uses memory (
AGENTS.md) as enforceable analytical standards (roundingrules, chart conventions) rather than persona context, and skills for three
distinct analysis workflows (exploratory, statistical, anomaly detection).
What's included
analyze.py— async streaming with Rich progress display showing each tool callAGENTS.md— analysis standards (rounding, chart formatting, reporting rules)exploratory-analysis,statistical-summary,anomaly-detectiondata/sample_sales.csv(103 rows) for immediate demoHow I verified
(
"Summarize this dataset","Which region has the highest revenue?","Find anomalies in daily revenue")DataReportoutput renders correctly in the terminaloutput/Disclaimer: This contribution was developed with the assistance of AI agents.