数据分析
- 作者仓库星标 7,870
- 作者更新于 实时读取
- 作者仓库 Upsonic
- 领域
- 设计与多媒体
- 兼容 Agent
-
- Claude Code
- Cursor
- Cline
- Codex
- Windsurf
- Gemini CLI
- +20
- 信任分
- 88 / 100 · 社区维护
- 作者 / 版本 / 许可
- @Upsonic · 未声明 license
- Token 消耗评级
- 低消耗
- 接入复杂程度
- 需简单配置
- 是否需要外部 API Key
- 不需要
- 兼容的系统
- 未声明(默认跨平台)
- 底层运行要求
- Python
- 文件与系统权限
-
- 只读
- 允许写入 / 修改
- Shell 执行
- 网络行为
- 仅限本地
- 安装命令数
- 26 条
档案由构建时根据 SKILL.md 与安装命令自动衍生,可能与作者实际意图存在差异。
需要注意: 未限定 allowed-tools,默认拥有全部工具权限。
---
name: data-analysis
description: Analyze, explore, clean, and visualize datasets with statistical rigor. Use when user asks to an…
category: 设计与多媒体
runtime: Python
---
# data-analysis 输出预览
## PART A: 任务判断
- 适用问题:视觉内容、演示材料、信息图或设计交付。
- 输入要求:目标材料、限制条件、期望输出和验收方式。
- 证据边界:围绕“Before You Analyze / Understand the Question / Reference Materials and Scripts”读取原文规则,不把推断写成作者承诺。
## PART B: 执行结果
- **01** 任务判断:确认你的需求是否属于视觉内容、演示材料、信息图或设计交付,并标出输入、限制和预期结果。
- **02** 执行计划:优先按“Before You Analyze / Understand the Question / Reference Materials and Scripts”拆成步骤,说明每一步会读取什么、修改什么、产出什么。
- **03** 交付结果:给出可复制的命令、文件改动、检查清单或内容草稿,并说明如何继续迭代。
- **04** 风险边界:结合 读取文件、写入/修改文件、执行终端命令、主要在本地完成、通常不需要额外 API Key 给出执行前确认项。
## Running Rules
- 读取文件、写入/修改文件、执行终端命令;主要在本地完成;通常不需要额外 API Key。
- 先小样例验证,再放大到真实任务。
- 交付时同时给结果、检查口径和下一步迭代建议。 原文没有稳定的斜杠命令要求。安装验证后通常全局生效,直接在对话里点名这个 Skill 并描述任务即可。
告诉 Agent 目标文件或材料、期望结果、不可改范围、是否允许联网或执行命令。本 Skill 的权限画像是:读取文件、写入/修改文件、执行终端命令。
先用一个小任务确认它会围绕“Before You Analyze / Understand the Question / Reference Materials and Scripts”工作;涉及文件或命令时,先看 diff、日志、预览或测试结果。
检查最终产物是否包含明确结果、必要证据和下一步动作;如果输出泛泛而谈,就补充输入、边界和验收标准后重跑。
---
name: data-analysis
description: Analyze, explore, clean, and visualize datasets with statistical rigor. Use when user asks to an…
category: 设计与多媒体
source: Upsonic/Upsonic
---
# data-analysis
## 什么时候使用
- 用于组织测试、定位失败并形成修复闭环 适合处理界面、视觉、封面、信息图或演示材料交付,核心价值是把输入、判断、执行、验证和交付边界固定下来,避免 Agent 泛泛回答。 把任务拆成可执行、可检查、可继续迭代的步骤;通常不需要额外 API…
- 面向视觉内容、演示材料、信息图或设计交付,优先处理能明确输入、步骤和验收标准的工作。
## 需要提供什么
- 目标材料、目录范围、期望结果和不可改动内容。
- 是否允许联网、执行命令、读写文件或调用外部服务。
## 执行规则
- 围绕「Before You Analyze / Understand the Question / Reference Materials and Scripts」组织步骤,不把推断写成作者事实。
- 读取文件、写入/修改文件、执行终端命令;主要在本地完成;通常不需要额外 API Key。
- 先跑小样例,确认结果可检查后再扩大任务范围。
## 输出要求
- 给出最终产物、关键证据、验证方式和下一步动作。
- 信息不足时标记 unknown,不编造命令、平台或依赖。 作者原文负责流程事实;仓库文件负责来源和命令;流狐只补充适用场景、限制和质量判断。
skill "data-analysis" {
输入层 -> 用户目标 + 目标文件 + 禁止范围 + 验收标准
上下文层 -> Before You Analyze / Understand the Question / Reference Materials and Scripts
规则层 -> SKILL.md 触发条件 / 执行顺序 / 输出格式
运行层 -> Python | 读取文件、写入/修改文件、执行终端命令 | 主要在本地完成
安全层 -> 通常不需要额外 API Key + 小任务验证 + diff / 日志复核
输出层 -> 可复制结果 + 检查清单 + 下一步迭代
} Data Analysis
Explore, clean, analyze, and communicate findings from data. The goal is always to answer a question — start with what the user wants to know and work backward to the analysis that answers it.
Before You Analyze
Understand the Question
Before touching the data, clarify:
- What question are we answering? ("Is our conversion rate improving?" is an answerable question. "Analyze this data" is not — help the user sharpen it.)
- Who needs the answer? (Engineer debugging an issue? Executive making a budget decision? Researcher testing a hypothesis?)
- What decisions will this inform? (This determines how precise you need to be and what format the answer should take.)
- What's the timeline? (A quick sanity check and a thorough statistical analysis require different approaches.)
If the user says "analyze this data" without a specific question, help them formulate one:
- "What would be most useful to know from this data?"
- "Are you looking for trends over time, comparisons between groups, or something else?"
- "Is there a specific business question this should answer?"
Reference Materials and Scripts
- Execute
profile_data.pywith a data file path to get a quick profile of any CSV, Excel, or JSON dataset — it reports shape, types, missing values, stats, and value distributions. Run with--helpfor usage. - Load
statistical-tests-guide.mdwhen choosing statistical tests — it has a decision matrix for test selection, effect size interpretation tables, and sample size guidelines.
Understand the Data
Before analysis, get your bearings:
- Source and context: Where did this data come from? How was it collected? What time period does it cover?
- Schema: What are the columns/fields? What do they represent? What are the data types?
- Scale: How many rows/records? What's the granularity? (Per user? Per day? Per transaction?)
- Known issues: Is the data known to be incomplete, biased, or have quality problems?
# First look at any dataset
import pandas as pd
df = pd.read_csv("data.csv") # or read_excel, read_json, etc.
print(f"Shape: {df.shape}")
print(f"\nColumn types:\n{df.dtypes}")
print(f"\nFirst rows:\n{df.head()}")
print(f"\nMissing values:\n{df.isnull().sum()}")
print(f"\nBasic stats:\n{df.describe()}")
Analysis Workflow
Step 1: Clean and Validate
Data quality determines analysis quality. Don't skip this.
Handle Missing Values
- Count them first: What percentage of each column is missing?
- Understand why: Are they random? Systematic? (e.g., optional fields vs data collection failures)
- Choose a strategy and document it:
- Drop rows: When missing data is rare and random (less than 5%)
- Impute with median/mode: When missing data is moderate and the distribution is known
- Flag as separate category: When missingness itself is informative
- Leave as-is: When the analysis method handles nulls natively
# Document your decisions
missing_pct = df.isnull().sum() / len(df) * 100
print("Missing data percentage per column:")
print(missing_pct[missing_pct > 0].sort_values(ascending=False))
Handle Outliers
- Detect: Use IQR method, z-scores, or domain knowledge
- Investigate: Are they errors or legitimate extreme values?
- Document your decision: Keep, cap, or remove — and explain why
# IQR method for outlier detection
Q1 = df['value'].quantile(0.25)
Q3 = df['value'].quantile(0.75)
IQR = Q3 - Q1
outliers = df[(df['value'] < Q1 - 1.5 * IQR) | (df['value'] > Q3 + 1.5 * IQR)]
print(f"Found {len(outliers)} outliers ({len(outliers)/len(df)*100:.1f}%)")
Validate Data Types and Ranges
- Dates should be dates, numbers should be numbers
- Check for impossible values (negative ages, future dates, percentages over 100)
- Verify categorical values are consistent (watch for "USA", "US", "United States")
Step 2: Explore
Start broad, then focus on what's interesting.
Descriptive Statistics
Always start here — understand the basics before going deeper.
# Numerical columns
print(df.describe())
# Categorical columns
for col in df.select_dtypes(include='object').columns:
print(f"\n{col}: {df[col].nunique()} unique values")
print(df[col].value_counts().head(10))
Distributions
Understanding shape matters for choosing the right tests.
import matplotlib.pyplot as plt
# Distribution of key metrics
fig, axes = plt.subplots(1, 3, figsize=(15, 5))
for i, col in enumerate(['metric_a', 'metric_b', 'metric_c']):
df[col].hist(ax=axes[i], bins=30)
axes[i].set_title(col)
axes[i].axvline(df[col].median(), color='red', linestyle='--', label='median')
axes[i].legend()
plt.tight_layout()
plt.savefig("distributions.png")
Correlations and Relationships
Look for patterns between variables.
# Correlation matrix for numerical columns
corr = df.select_dtypes(include='number').corr()
print("Strong correlations (|r| > 0.5):")
for i in range(len(corr.columns)):
for j in range(i+1, len(corr.columns)):
if abs(corr.iloc[i, j]) > 0.5:
print(f" {corr.columns[i]} vs {corr.columns[j]}: {corr.iloc[i,j]:.3f}")
Trends Over Time
If the data has a time dimension, always look at trends.
# Time series analysis
df['date'] = pd.to_datetime(df['date'])
daily = df.groupby('date')['metric'].agg(['mean', 'count'])
daily['mean'].plot(figsize=(12, 4), title='Daily Average')
plt.savefig("trend.png")
Step 3: Analyze
Choose the right method for the question.
Comparison Questions ("Is A different from B?")
Use the right statistical test:
- Two groups, continuous outcome: t-test (if normal) or Mann-Whitney U (if not)
- Multiple groups: ANOVA (if normal) or Kruskal-Wallis (if not)
- Two groups, categorical outcome: Chi-squared test
- Before/after with same subjects: Paired t-test or Wilcoxon signed-rank
Always report:
- Sample sizes for each group
- Effect size (not just p-value) — Cohen's d, odds ratio, or percentage difference
- Confidence intervals
- Practical significance, not just statistical significance
from scipy import stats
# Example: comparing two groups
group_a = df[df['variant'] == 'A']['metric']
group_b = df[df['variant'] == 'B']['metric']
# Check normality first
_, p_normal_a = stats.shapiro(group_a.sample(min(5000, len(group_a))))
_, p_normal_b = stats.shapiro(group_b.sample(min(5000, len(group_b))))
if p_normal_a > 0.05 and p_normal_b > 0.05:
stat, p_value = stats.ttest_ind(group_a, group_b)
test_name = "t-test"
else:
stat, p_value = stats.mannwhitneyu(group_a, group_b)
test_name = "Mann-Whitney U"
# Effect size (Cohen's d)
pooled_std = ((group_a.std()**2 + group_b.std()**2) / 2) ** 0.5
cohens_d = (group_a.mean() - group_b.mean()) / pooled_std
print(f"Test: {test_name}")
print(f"Group A: mean={group_a.mean():.3f}, n={len(group_a)}")
print(f"Group B: mean={group_b.mean():.3f}, n={len(group_b)}")
print(f"Difference: {group_a.mean() - group_b.mean():.3f} ({(group_a.mean() - group_b.mean())/group_b.mean()*100:.1f}%)")
print(f"Cohen's d: {cohens_d:.3f}")
print(f"p-value: {p_value:.4f}")
Trend Questions ("Is this changing over time?")
- Use rolling averages to smooth noise
- Look for seasonality (day-of-week, monthly, quarterly patterns)
- Segment by key dimensions — overall trends can mask group-level differences
- Compare period-over-period (WoW, MoM, YoY)
Composition Questions ("What's the breakdown?")
- Use percentages and proportions
- Show both absolute numbers and percentages
- Look for the Pareto principle (80/20 rule)
- Segment into meaningful groups
A/B Test Analysis
For experiment analysis, follow this checklist:
- Sample size: Was the test adequately powered?
- Duration: Did it run long enough for weekly patterns?
- Randomization: Were groups balanced on key dimensions?
- Metric definition: Is the metric clearly defined and correctly computed?
- Statistical test: Use the appropriate test for the metric type
- Multiple comparisons: Correct for multiple testing if checking many metrics
- Practical significance: Is the effect large enough to matter?
Step 4: Communicate Findings
Structure matters as much as the analysis itself.
Lead With the Answer
Start with what the user asked. Then support it.
Pattern:
[Answer to the question in 1-2 sentences]
[Key supporting evidence: 2-4 bullet points with specific numbers]
[Methodology note: How you arrived at this, in 1-2 sentences]
[Caveats and limitations: What could affect this conclusion]
[Recommended next steps: What to do with this information]
Visualization Guidelines
Choose the right chart type:
- Trend over time: Line chart
- Comparison between categories: Bar chart (horizontal for many categories)
- Distribution: Histogram or box plot
- Relationship between two variables: Scatter plot
- Part-of-whole: Stacked bar or pie chart (only for 2-5 categories)
- Multiple dimensions: Heatmap or small multiples
For every chart:
- Title that states the finding, not just the data ("Conversion drops 40% on weekends" not "Conversion by day")
- Label axes with units
- Include sample size or time period
- Use consistent colors across related charts
What to Always Include
- Sample sizes: How much data backs each claim
- Time periods: When the data is from
- Definitions: How key metrics are calculated
- Confidence: How certain you are (confidence intervals, p-values where appropriate)
- Limitations: What the data can't tell you
Common Pitfalls
- Survivorship bias: Only analyzing data from things that succeeded/persisted
- Simpson's paradox: A trend that appears in groups but reverses when combined
- Confounding variables: Correlation doesn't mean causation — look for third variables
- Small sample sizes: Don't draw strong conclusions from small N. State the limitation.
- Cherry-picking timeframes: Make sure the time period is representative
- Precision theater: Reporting "23.847%" when the data only supports "roughly 24%"
- Missing baseline: A number without context is meaningless ("10,000 errors" — is that a lot?)
Handling Common Requests
"Just give me a quick look"
Provide: shape, column summary, missing data count, top-level descriptive stats, one key insight. Keep it to one screen of output.
"What's interesting in this data?"
Run the full exploration workflow (Step 2) and surface the 3-5 most notable patterns: unexpected distributions, strong correlations, outliers, trends.
"Is this statistically significant?"
Clarify what comparison they mean, choose the right test, report effect size and p-value, and explain what it means in practical terms.
"Create a dashboard / visualization"
Ask what decisions the dashboard supports. Design 3-5 charts that answer those questions. Use consistent styling and clear titles that state findings.
先判断是否适合
作者设计意图
作者的方法与取舍
边界和复核