Skip to content

Instantly share code, notes, and snippets.

@will-gao42
Last active December 14, 2021 17:37
Show Gist options
  • Save will-gao42/7914f17b666dd3ff4dea37d770b1ce51 to your computer and use it in GitHub Desktop.
Save will-gao42/7914f17b666dd3ff4dea37d770b1ce51 to your computer and use it in GitHub Desktop.
EDA data processing snippets
def trim(df, col, qt):
"""
Trim certain percentiles on both sides of a dataframe
"""
p1 = df[col].quantile(qt)
p2 = df[col].quantile(1-qt)
trimmed_df = df[df[col].between(p1, p2)]
return trimmed_df
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment