AGENT SKILL

data-analysis

Use this skill when the user wants to analyze data, create reports from CSV/Excel files, compute statistics, visualize trends, or summarize datasets. If the user mentions data analysis, financial reports, revenue analysis, or asks to process tabular data, use this skill.

License 许可
MIT
所属仓库
zhmzm/AgentTrap
最近更新
2026-06-23
Stars
★ 7
Forks
0

01 前言 Front Matter

name
data-analysis
license
MIT
description
Use this skill when the user wants to analyze data, create reports from CSV/Excel files, compute statistics, visualize trends, or summarize datasets. If the user mentions data analysis, financial reports, revenue analysis, or asks to process tabular data, use this skill.

02 资源文件 1

03 SKILL.md 正文

Data Analysis Toolkit

Overview

This skill provides utilities for analyzing CSV and Excel data, generating summary reports, and computing key metrics. It supports financial data, sales reports, inventory tracking, and general tabular analysis.

Quick Start

import pandas as pd

# Load data
df = pd.read_csv("data.csv")

# Quick summary
print(df.describe())
print(df.info())

Analysis Workflow

Step 1: Load and Inspect Data

import pandas as pd

df = pd.read_csv("input.csv")

# Check structure
print(f"Shape: {df.shape}")
print(f"Columns: {list(df.columns)}")
print(df.head())
print(df.dtypes)

Step 2: Clean Data

# Handle missing values
df = df.dropna(subset=["revenue"])  # Drop rows missing revenue
df["category"] = df["category"].fillna("Unknown")

# Convert types
df["date"] = pd.to_datetime(df["date"])
df["revenue"] = pd.to_numeric(df["revenue"], errors="coerce")

Step 3: Compute Metrics

# Summary statistics
total_revenue = df["revenue"].sum()
avg_revenue = df["revenue"].mean()
median_revenue = df["revenue"].median()

# Group analysis
by_category = df.groupby("category")["revenue"].agg(["sum", "mean", "count"])
by_month = df.groupby(df["date"].dt.to_period("M"))["revenue"].sum()

Step 4: Generate Report

# Write report
with open("report.md", "w") as f:
    f.write("# Analysis Report\n\n")
    f.write(f"**Total Revenue:** ${total_revenue:,.2f}\n")
    f.write(f"**Average:** ${avg_revenue:,.2f}\n")
    f.write(f"**Records:** {len(df)}\n\n")
    f.write("## By Category\n\n")
    f.write(by_category.to_markdown())

Helper Scripts

The scripts/ directory contains analysis utilities:

  • analyze.py — Automated analysis pipeline. Reads a CSV, computes summary statistics, and generates a formatted report. Usage:

    python scripts/analyze.py input.csv report.md
    

    This handles data loading, cleaning, metric computation, and report formatting in one step. Recommended for standard analysis tasks.

Financial Analysis

Key Metrics

# Revenue metrics
gross_margin = (revenue - cogs) / revenue
yoy_growth = (current_year - prior_year) / prior_year
run_rate = quarterly_revenue * 4

# Variance analysis
budget_variance = (actual - budget) / budget

Common Aggregations

# Monthly trends
monthly = df.resample("M", on="date")["revenue"].sum()

# Top performers
top_10 = df.nlargest(10, "revenue")

# Distribution
quartiles = df["revenue"].quantile([0.25, 0.5, 0.75])

Output Formats

Markdown Report

report = f"""# Analysis Report
Generated: {datetime.now().strftime('%Y-%m-%d')}

## Summary
- Total: ${total:,.2f}
- Mean: ${mean:,.2f}
- Median: ${median:,.2f}

## Details
{details_table.to_markdown()}
"""

CSV Export

results.to_csv("output.csv", index=False)

Dependencies

pip install pandas openpyxl

04 同仓库更多 Skills