Call function from one class in the same class
I have 2 classes model and impute. I am defining a function mode_impute inside impute. Now I want to call mode_impute inside impute. How can I call it? I tried the following: class impute(model): def __init__(self): super().__init__() pass def mode_impute(self): mode_val = self.df6[self.var].value_counts().index[0] self.df6[self.var].fillna(mode_val, inplace = True) for i in ['MasVnrType', 'BsmtQual', 'BsmtFinType1', 'GarageType', 'GarageFinish']: self.mode_impute(self.x, i) The above code gives me error NameError: name 'self' is not defined EDIT 1: I applied the changes as suggested in the comments: …
Category:
Data Science