def drop_na(data: Dataset) -> Dataset: data = data.copy() tmp_concat = pd.concat([data.X, pd.DataFrame(data.y, columns=["_TARGET_"])], axis=1) tmp_concat.dropna(inplace=True) tmp_concat.reset_index(drop=True, inplace=True) data.X = tmp_concat.drop(columns=["_TARGET_"]).copy() data.y = tmp_concat["_TARGET_"].copy().to_numpy().ravel() return data
def concat(data: Dataset) -> pd.DataFrame: data = data.copy() return pd.concat([data.X, pd.DataFrame(data.y, columns=["_TARGET_"])], axis=1)
def convert_protected(data: Dataset) -> Tuple[Dataset, LabelEncoder]: data = data.copy() encoder = LabelEncoder() for feature in data.protected_features: data.X[feature] = encoder.fit_transform(data.X[feature]) return data, encoder