I do have a data frame with so many cols. I would like to apply cbrt transformation first and then StandardScaler() to some specific cols in a dataframe for each month but I received some errors
df=pd.DataFrame({'month':['1','1','1','1','1','2','2','2','2','2','2','2'],'X1':
[30,42,25,32,12,10,4,6,5,10,24,21],'X2':[10,76,100,23,65,94,67,24,67,54,87,81],'X3':
[23,78,95,52,60,76,68,92,34,76,34,12]})
df
My code below is but no worries about Month
df['X1']=pd.Series(np.cbrt(df['X1'])).values
Below is for but needs to consider group month
from sklearn.preprocessing import StandardScaler
scaler = StandardScaler()
df['X1_scale'] = scaler.group('Month').fit(df['X1'])
I would like to combine these two operations on a autamated function that adds column X1_Scale and X2_Scale but since I have so many cols I would like to do this on first 2 cols (df.loc[:,2:3]) in general. Please help. Thank you.