Transformations by group

Aperta
#460 1 commento 0 reazioni 0 assegnatari Vedi su GitHub

I maintainer di solito rispondono entro 1 giorno

Nessuno ha ancora preso questa issue.

Valutazione

Difficoltà
5/5
Tempo stimato
Più di una settimana
Idoneità per principianti
35/100
Tipo di issue
Funzionalità
Chiarezza
Abbastanza chiara
Stato di attività
Ferma
Stack tecnologico
pandas, python

Direzione di ricerca

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.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

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.

Lingua principale
Python
Stelle
2.3k
Fork
391
Merge medio
11h 34m
PR unite (30g)
11

Preparare l'ambiente

Questo progetto non fornisce container di sviluppo, Dockerfile né guida per i contributori, quindi l'ambiente è a tuo carico: parti dal suo README e consulta la nostra guida al primo contributo per i passaggi generali.

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di feature-engine/feature_engine

Tutte le issue di feature-engine/feature_engine

Issue simili

Altre issue su Python

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.