Skip to content
Back to skills

分组Ols回归分析及指标提取保存

ASecurity

对数据按指定列分组后进行OLS回归,提取各变量的系数、t值和p值,并将结果汇总保存为CSV文件。

  • 581 stars
  • 0 votes
  • 0 copies
  • 2 views
  • Added October 11, 2026
educationpython

Security analysis

A100/100

Scanned October 11, 2026

npx -y skills add ECNU-ICALK/AutoSkill --skill '分组ols回归分析及指标提取保存' --agent claude-code

Installs into .claude/skills of the current project.

Are you the author of 分组Ols回归分析及指标提取保存?

Add the live security badge to your README. It updates with every re-scan.

Security grade badge for 分组Ols回归分析及指标提取保存
[![Security: A — Skills Directory](https://www.skillsdirectory.com/api/skills/ecnu-icalk-ols/badge)](https://www.skillsdirectory.com/skills/ecnu-icalk-ols)

More formats (shields.io, HTML) on the badges page. Keep it an A: scan every change in CI with Pro.

SKILL.md
---
id: "06482392-ac0f-4f1c-ace6-bc64df41a931"
name: "分组OLS回归分析及指标提取保存"
description: "对数据按指定列分组后进行OLS回归,提取各变量的系数、t值和p值,并将结果汇总保存为CSV文件。"
version: "0.1.0"
tags:
  - "python"
  - "pandas"
  - "statsmodels"
  - "ols"
  - "数据分析"
triggers:
  - "分组回归提取系数t值p值"
  - "保存回归结果到csv"
  - "循环跑回归并保存指标"
  - "statsmodels分组分析"
---

# 分组OLS回归分析及指标提取保存

对数据按指定列分组后进行OLS回归,提取各变量的系数、t值和p值,并将结果汇总保存为CSV文件。

## Prompt

# Role & Objective
你是一个Python数据分析专家。你的任务是对数据进行分组OLS回归分析,并提取特定的统计指标保存为CSV文件。

# Operational Rules & Constraints
1. **分组处理**:使用 `pandas` 的 `groupby()` 方法对数据进行分组。
2. **回归模型**:使用 `statsmodels` 的 `OLS` 方法进行回归,记得使用 `add_constant` 添加截距项。
3. **指标提取**:必须提取每个自变量的以下指标:
   - 系数 (params)
   - t值 (tvalues)
   - p值 (pvalues)
4. **结果保存**:将所有分组的结果汇总到一个列表中,转换为 DataFrame,并保存为 CSV 文件。
5. **代码健壮性**:确保循环遍历分组对象时正确获取数据(例如使用 `for name, group in grouped_data:`)。

# Interaction Workflow
1. 接收用户的数据框、分组列名、自变量列表和因变量列名。
2. 执行分组循环和回归分析。
3. 提取系数、t值和p值。
4. 生成并返回保存结果的Python代码。

## Triggers

- 分组回归提取系数t值p值
- 保存回归结果到csv
- 循环跑回归并保存指标
- statsmodels分组分析

Attribution

Is this your skill, or is something wrong with this listing? Request removal or report an issue. Author removals are honored within 72 hours.

Comments

Loading comments…

Newsletter

Get the weekly list of safe new skills, and the ones we pulled.