2
내 DataFrame을 특정 열로 그룹화 한 다음 Sklearn 사전 처리 MinMaxScaler를 적용하고 스케일러 개체를 저장하려고합니다.skandarn groupby와 sklearn 전처리 과정의 조합
순간 시작 지점에서내 :
import pandas as pd
from sklearn import preprocessing
scaler = {}
groups = df.groupby('ID')
for name, group in groups:
scr = preprocessing.MinMaxScaler()
scr.fit(group)
scaler.update({name: scr})
group = scr.transform(group)
는 df.groupby('ID').transform
으로이 가능합니까? 내 원래 DataFrame
pd.DataFrame(dict(ID=list('AAABBB'),
VL=(0,10,10,100,100,200))
에서
UPDATE
나는 ID를 기반으로 모든 열을 확장합니다. 이 예에서 : 정보/스케일러 객체
A 0.0
A 1.0
A 1.0
B 0.0
B 0.0
B 1.0
preprocessing.MinMaxScaler().fit(...)