Question: Help creating a custom transformer in Python. I need to create a custom transformer that takes in a data set (alpha1) column names A, B,
Help creating a custom transformer in Python.
I need to create a custom transformer that takes in a data set (alpha1) column names A, B, C, D, E. (A,B,C,E is numerical data and D is categorical)
I need it to return a column 'F' that does B^2/E. F=B**2/E
It should include a parameter with a default value of `True` that deletes the column C when its value is `True`, but preserves the column C when its value is `False`. End result basically drops this column.
Then I need it to not transform column D which is categorical data.
Ending Dataset should be A,B,D,E,F
Please include explanations on why you did steps a certain way.
Edit to add some example data for the data frame
Data Frame alpha1
Column
A 3 6 9 12 15
B 6 12 18 24 30
C 581 582 581 524 585 (needs to drop column when value is True, but not when Value is false)
D Hot Cold Warm Hot Cold (don't want this to be touched by transformer; will hot encode it later)
E 3 6 3 4 5
F(new column created from B**2/E)
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
