Skip to content

Instantly share code, notes, and snippets.

@HeenaR17
Created April 3, 2021 15:29
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save HeenaR17/94cd246bc63ab0d8bc7115ac213f3425 to your computer and use it in GitHub Desktop.
Save HeenaR17/94cd246bc63ab0d8bc7115ac213f3425 to your computer and use it in GitHub Desktop.
##checking outliers
outliers=[]
def detect_outliers(data):
threshold=3 #3rd std deviation
mean=np.mean(data)
std=np.std(data)
for i in data:
z_score=(i-mean)/std
if np.abs(z_score)>threshold:
outliers.append(i)
return outliers
outlier=detect_outliers(df['Age'])
outlier
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment