Transformations by group

未关闭
#460 1 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看

维护者通常 1 天内回复

还没有人认领这个 Issue。

评估

难度
5/5
预计耗时
一周以上
新手友好度
35/100
Issue 类型
功能
描述清晰度
基本清楚
活跃度
停滞
技术栈
pandas, python

调研方向

Start by reading the project’s existing feature-engineering transformer documentation and tests to see how new transformations fit its API. The issue gives a pandas groupby-transform example but does not specify the interface or supported summaries. Done means users can create group-level summary variables that are repeated for each row in the group.

由索引模型根据 Issue 内容生成。

描述

duplicate

Is there support for creating new variables that are summaries of existing variables by group? I can't seem to find it.

For example:

import pandas as pd

df = pd.DataFrame({
    'group': ['A', 'A', 'B', 'B', 'B', 'A'],
    'x1': [0.1, 0.2, 0.3, 0.4, 0.5, 0.6],
    'x2': [0.7, 0.8, 0.9, 0.1, 0.2, 0.3]
})

# new variables: mean of x1 and x2 by group
df[["x1_mean", "x2_mean"]] = df.groupby('group')[['x1', 'x2']].transform("mean")
print(df)
  group   x1   x2  x1_mean  x2_mean
0     A  0.1  0.7      0.3      0.6
1     A  0.2  0.8      0.3      0.6
2     B  0.3  0.9      0.4      0.4
3     B  0.4  0.1      0.4      0.4
4     B  0.5  0.2      0.4      0.4
5     A  0.6  0.3      0.3      0.6

This type of feature engineering is usually helpful.

主要语言
Python
星标
2.3k
派生
391
平均合并
11 小时 34 分钟
30 天内合并 PR
11

环境准备

这个项目没有提供开发容器、Dockerfile 或贡献指南,环境需要你自己搭建:先看它的 README,通用步骤见我们的新手贡献指南。

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

feature-engine/feature_engine 的其他 Issue

查看 feature-engine/feature_engine 的全部 Issue

相似的 Issue

更多 Python Issue

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。