用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
直接命令不会经过审查 Prompt;运行前请先检查来源。
npx skills add https://github.com/aiskillstore/marketplace --skill bi-analyst命令会保持在同一行。复制前请横向滚动并检查完整内容。
想先保存到本地?可下载 SkillsMP 当前能够提供的文件。
基于 SOC 职业分类
正在显示 SKILL.md
| name | bi-analyst |
| category | software-engineering |
| description | BI/数据分析工程师 Agent — 覆盖数据采集、ETL、指标体系建设、可视化看板、专题分析、数据产品全流程。支持SQL查询、Python分析、BI工具集成、自动化报表、A/B测试分析。 |
当用户提出以下需求时加载此技能:
先明确以下信息:
SQL查询(数据库场景)
-- 典型查询模板:用户留存分析
SELECT
DATE(first_active) AS active_date,
COUNT(DISTINCT user_id) AS new_users,
COUNT(DISTINCT CASE WHEN DATEDIFF(login_date, first_active) = 1 THEN user_id END) AS day1_retained,
COUNT(DISTINCT CASE WHEN DATEDIFF(login_date, first_active) = 7 THEN user_id END) AS day7_retained
FROM (
SELECT
u.user_id,
MIN(u.login_date) OVER (PARTITION BY u.user_id) AS first_active,
u.login_date
FROM user_login u
) t
WHERE login_date >= '2024-01-01'
GROUP BY first_active
ORDER BY first_active;
CSV/Excel文件读取(Python)
import pandas as pd
df = pd.read_csv('data.csv')
# 或 pd.read_excel('data.xlsx', sheet_name='Sheet1')
import pandas as pd
import numpy as np
# 基础清洗
df = df.drop_duplicates()
df = df.dropna(subset=['关键字段'])
df['date'] = pd.to_datetime(df['date'])
df['amount'] = pd.to_numeric(df['amount'], errors='coerce')
# 异常值处理
df = df[df['amount'] > 0] # 过滤负值
df['amount'].fillna(df['amount'].median(), inplace=True)
# 类型转换
df['category'] = df['category'].astype('category')
# 留存分析
cohort = df.groupby('cohort_date').agg(
new_users=('user_id', 'nunique'),
day1_retention=('is_day1_active', 'mean'),
day7_retention=('is_day7_active', 'mean'),
day30_retention=('is_day30_active', 'mean')
)
# 漏斗分析
funnel = df.groupby('step').agg(
users=('user_id', 'nunique'),
conversion_rate=('converted', 'mean')
)
funnel['step_conversion'] = funnel['users'] / funnel['users'].shift(1)
# 同期群分析(Cohort Analysis)
cohort = df.groupby(['cohort_month', 'period']).agg(
users=('user_id', 'nunique')
)
cohort['retention_rate'] = cohort.groupby(level=0)['users'].transform(
lambda x: x / x.iloc[0]
)
Python可视化(matplotlib/seaborn/plotly)
import matplotlib.pyplot as plt
import seaborn as sns
import plotly.express as px
# 折线图:趋势分析
plt.figure(figsize=(12, 6))
sns.lineplot(data=df, x='date', y='revenue', hue='channel')
plt.title('各渠道收入趋势')
plt.xticks(rotation=45)
plt.tight_layout()
plt.savefig('revenue_trend.png')
# 热力图:留存矩阵
pivot = df.pivot_table(index='cohort', columns='period', values='retention_rate')
sns.heatmap(pivot, annot=True, fmt='.1%', cmap='YlOrRd')
plt.title('留存热力图')
plt.tight_layout()
plt.savefig('retention_heatmap.png')
# 交互式图表(plotly)
fig = px.line(df, x='date', y='metric', color='dimension', title='指标趋势')
fig.write_html('interactive_chart.html')
BI工具集成(Metabase/Superset)
用户留存分析
# 同期群留存
cohort_data = df.groupby(['cohort_date', 'period']).agg(
users=('user_id', 'nunique')
).reset_index()
cohort_data['retention'] = cohort_data.groupby('cohort_date')['users'].transform(
lambda x: x / x.iloc[0]
)
漏斗分析
funnel_steps = ['曝光', '点击', '注册', '下单', '支付']
funnel_data = []
for step in funnel_steps:
funnel_data.append({
'step': step,
'users': df[df['step_rank'] >= funnel_steps.index(step)]['user_id'].nunique()
})
funnel_df = pd.DataFrame(funnel_data)
funnel_df['step_conversion'] = funnel_df['users'] / funnel_df['users'].shift(1)
funnel_df['overall_conversion'] = funnel_df['users'] / funnel_df['users'].iloc[0]
A/B测试分析
from scipy import stats
# 假设检验
control = df[df['group'] == 'control']['conversion']
treatment = df[df['group'] == 'treatment']['conversion']
# Z检验 / t检验
stat, p_value = stats.ttest_ind(treatment, control)
# 或比例检验
from statsmodels.stats.proportion import proportions_ztest
# 效应量
from scipy.stats import chi2_contingency
Python脚本生成Excel报表
import pandas as pd
from openpyxl import load_workbook
from openpyxl.styles import Font, PatternFill, Alignment, Border, Side
with pd.ExcelWriter('daily_report.xlsx', engine='openpyxl') as writer:
summary_df.to_excel(writer, sheet_name='概览', index=False)
detail_df.to_excel(writer, sheet_name='明细', index=False)
funnel_df.to_excel(writer, sheet_name='漏斗分析', index=False)
定时任务(cron)
# 每天早8点运行报表
0 8 * * * cd /path/to/project && python daily_report.py
星型模型设计
-- 事实表
CREATE TABLE fact_orders (
order_id BIGINT,
user_id BIGINT,
product_id BIGINT,
date_id INT,
amount DECIMAL(10,2),
quantity INT
);
-- 维度表
CREATE TABLE dim_user (
user_id BIGINT PRIMARY KEY,
register_date DATE,
city VARCHAR(50),
channel VARCHAR(50)
);
CREATE TABLE dim_product (
product_id BIGINT PRIMARY KEY,
product_name VARCHAR(100),
category VARCHAR(50),
price DECIMAL(10,2)
);
CREATE TABLE dim_date (
date_id INT PRIMARY KEY,
date DATE,
year INT,
month INT,
day INT,
weekday VARCHAR(10),
is_holiday BOOLEAN
);
Airflow DAG模板
from airflow import DAG
from airflow.operators.python import PythonOperator
from datetime import datetime, timedelta
default_args = {
'owner': 'analyst',
'depends_on_past': False,
'start_date': datetime(2024, 1, 1),
'retries': 1,
'retry_delay': timedelta(minutes=5),
}
dag = DAG(
'daily_report',
default_args=default_args,
schedule_interval='0 8 * * *', # 每天8点
catchup=False
)
def generate_daily_report():
# 1. 从数据库取数
# 2. 计算指标
# 3. 生成图表
# 4. 发送邮件/推送
pass
task = PythonOperator(
task_id='run_daily_report',
python_callable=generate_daily_report,
dag=dag
)
from scipy import stats
import statsmodels.api as sm
# A/B测试显著性检验
def ab_test_analysis(control_conv, treatment_conv, control_n, treatment_n):
"""两样本比例检验"""
count = [treatment_conv, control_conv]
nobs = [treatment_n, control_n]
z_stat, p_value = statsmodels.stats.proportion.proportions_ztest(count, nobs)
return z_stat, p_value
# 相关性分析
corr = df[['metric1', 'metric2', 'metric3']].corr()
# 回归分析
X = df[['feature1', 'feature2']]
X = sm.add_constant(X)
y = df['target']
model = sm.OLS(y, X).fit()
print(model.summary())
Markdown报告
# 月度经营分析报告
## 核心指标概览
| 指标 | 本月 | 上月 | 环比 | 同比 |
|------|------|------|------|------|
| GMV | ¥1,200万 | ¥1,050万 | +14.3% | +25.0% |
| 活跃用户 | 85万 | 78万 | +9.0% | +18.1% |
| 转化率 | 3.2% | 3.0% | +0.2pp | +0.5pp |
## 关键发现
1. **增长亮点**:新渠道获客成本下降30%,ROI提升至4.5
2. **风险点**:老用户复购率连续3月下滑,需关注
3. **建议**:优化新用户引导流程,预计可提升次日留存5%
PDF报告(fpdf2)
chinese-pdf-generation 技能生成含中文图表的PDF报告def data_quality_check(df):
"""数据质量检查"""
report = {
'行数': len(df),
'列数': len(df.columns),
'缺失值': df.isnull().sum().to_dict(),
'缺失率': (df.isnull().sum() / len(df)).to_dict(),
'重复行': df.duplicated().sum(),
'数据类型': df.dtypes.to_dict(),
'描述统计': df.describe().to_dict()
}
return report
# 数据库连接
mysql -h host -u user -p database
psql -h host -U user -d database
# CSV快速查看
head -20 data.csv | column -t -s ','
wc -l data.csv
# Python快速分析
python -c "
import pandas as pd
df = pd.read_csv('data.csv')
print(df.describe())
print(df.isnull().sum())
"