Skip to content

Instantly share code, notes, and snippets.

@crodriguez1a
Created June 16, 2022 18:10
Show Gist options
  • Save crodriguez1a/0214db9d315912c21b2b57e0beb5383a to your computer and use it in GitHub Desktop.
Save crodriguez1a/0214db9d315912c21b2b57e0beb5383a to your computer and use it in GitHub Desktop.
from pandas import DataFrame, Series
def compute_bounds(series: DataFrame) -> tuple:
Q1:Series = series.quantile(0.25)
Q3:Series = series.quantile(0.75)
IQR:np.float = Q3 - Q1
lower_lim: float = Q1 - 1.5 * IQR
upper_lim: float = Q3 + 1.5 * IQR
return (lower_lim, upper_lim)
# compute_bounds(df.Age) -> (20.0, 92.0)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment