class DataFrame_Categorical_Imputer(): def __init__(self): print("Imputation object created") def fit(self, data): """ This method will fit impute mode value for all missing categoriical variables """ self.fill = pd.Series([data[column].\ value_counts().index[0] if data[column].dtype == np.dtype('O') else \ data[column].mode() for column in data], index=data.columns) return self
Preview:
downloadDownload PNG
downloadDownload JPEG
downloadDownload SVG
Tip: You can change the style, width & colours of the snippet with the inspect tool before clicking Download!
Click to optimize width for Twitter