Skip to content

Instantly share code, notes, and snippets.

@elijahbenizzy
Created September 2, 2023 22:15
Show Gist options
  • Save elijahbenizzy/f8cf4ae6f189fdb0a306c3827c2ee51e to your computer and use it in GitHub Desktop.
Save elijahbenizzy/f8cf4ae6f189fdb0a306c3827c2ee51e to your computer and use it in GitHub Desktop.
Feature Engineering -- Common Operations
def is_male(gender: pd.Series) -> pd.Series:
return gender == "male"
def is_female(gender: pd.Series) -> pd.Series:
return gender == "female"
def is_high_roller(budget: pd.Series) -> pd.Series:
return budget > 100
def age_normalized(age: pd.Series, age_mean: float, age_stddev: float) -> pd.Series:
return (age - age_mean) / age_stddev
def time_since_last_login(execution_time: datetime, last_logged_in: pd.Series) -> pd.Series:
return execution_time - last_logged_in
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment