Closed
Description
It is possible to apply several transformations to a single column. But is it possible to do it vice versa, i.e. like:
df = pd.DataFrame({
'cat_first': list('abaabababb'),
'cat_second': list('yyyynyynny'),
'num_first': list(range(10)),
'num_second': list(np.random.normal(size=10))
})
mapper = DataFrameMapper([
(['cat_first', 'cat_second'], LabelBinarizer()),
(['num_first', 'num_second'], StandardScaler())
], df_out=True)
output_df = mapper.fit_transform(df)
# dataframe contains 4 columns with transformed features
I know that list syntax like ['cat_first', 'cat_second']
is reserved to pass several columns into single transformer, but is it possible to somehow configure mapper to treat this syntax in a way that I've described above? Or do I need just repeat columns as separate items, like:
mapper = DataFrameMapper([
('cat_first', LabelBinarizer()),
('cat_second', LabelBinarizer()),
# etc ...
])
Metadata
Metadata
Assignees
Labels
No labels