qolmat.imputations.imputers.ImputerShuffle¶
- class qolmat.imputations.imputers.ImputerShuffle(groups: Tuple[str, ...] = (), random_state: Optional[Union[int, RandomState]] = None)[source]¶
Impute using random samples from the considered column.
- Parameters
- groups: Tuple[str, …]
List of column names to group by, by default []
- random_stateRandomSetting, optional
Determine the randomness of the imputer, by default None
Examples
>>> import numpy as np >>> import pandas as pd >>> from qolmat.imputations import imputers >>> imputer = imputers.ImputerShuffle(random_state=42) >>> df = pd.DataFrame( ... data=[ ... [1, 1, 1, 1], ... [np.nan, np.nan, np.nan, np.nan], ... [1, 2, 2, 5], ... [2, 2, 2, 2], ... ], ... columns=["var1", "var2", "var3", "var4"], ... ) >>> imputer.fit_transform(df) var1 var2 var3 var4 0 1.0 1.0 1.0 1.0 1 2.0 1.0 2.0 2.0 2 1.0 2.0 2.0 5.0 3 2.0 2.0 2.0 2.0