Last active
December 14, 2021 17:37
-
-
Save will-gao42/7914f17b666dd3ff4dea37d770b1ce51 to your computer and use it in GitHub Desktop.
EDA data processing snippets
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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