Skip to content

Instantly share code, notes, and snippets.

@adhadse
Created April 5, 2021 04:14
Show Gist options
  • Save adhadse/1bb0e50152031d9b22adac71d1e572e8 to your computer and use it in GitHub Desktop.
Save adhadse/1bb0e50152031d9b22adac71d1e572e8 to your computer and use it in GitHub Desktop.
def determine_outlier_thresholds_iqr(dataframe, col_name, th1=0.25, th3=0.75):
quartile1 = dataframe[col_name].quantile(th1)
quartile3 = dataframe[col_name].quantile(th3)
iqr = quartile3 - quartile1
upper_limit = quartile3 + 1.5 * iqr
lower_limit = quartile1 - 1.5 * iqr
return lower_limit, upper_limit
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment