Nov-15-2018, 04:39 AM
Hi everyone,
I have written a function and I want it to:
1) have inplace=True so it overrides what is in the df
2) loops through all variables in the df
My function is below:
I appreciate any help.
Thanks
I have written a function and I want it to:
1) have inplace=True so it overrides what is in the df
2) loops through all variables in the df
My function is below:
def binning(var): bin_list = [] for i in var: if i <= np.percentile(var, 25): bin_list.append(1) elif i <= np.percentile(var, 50): bin_list.append(2) elif i <= np.percentile(var, 75): bin_list.append(3) else: bin_list.append(4) return bin_list print(binning(credit["PAY_0"].values))I have about 20 variables I'd like it to go through.
I appreciate any help.
Thanks