Skip to content

Instantly share code, notes, and snippets.

Created Aug 6, 2022
What would you like to do?
Remove Dangerous Features
import numpy as np
import pandas as pd
V3 = frozenset(
V4 = frozenset(
def remove_dangerous_features(
df: pd.DataFrame,
copy: bool = True,
) -> pd.DataFrame:
if len([x for x in df.columns if x in V3]) == len(V3):
bad_features = V3
elif len([x for x in df.columns if x in V4]) == len(V4):
bad_features = V4
raise RuntimeError("Unknown dataset")
if copy:
tmp = df.copy()
tmp = df
tmp[list(bad_features)] = replacement_value
return tmp
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment