Created
October 2, 2022 19:18
-
-
Save lesutton/542c80e0d97b78c2dcf41d80546242a5 to your computer and use it in GitHub Desktop.
Calculate Outliers
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
plt.boxplot(dataframe['Age']) | |
plt.title('Boxplot of Age with Outlier Details Below') | |
plt.ylabel('Age') | |
plt.show() | |
def get_outliers(df): | |
q1=df.quantile(0.25) | |
q3=df.quantile(0.75) | |
IQR=q3-q1 | |
outliers = df[((df<(q1-1.5*IQR)) | (df>(q3+1.5*IQR)))] | |
return outliers | |
outliers = get_outliers(dataframe['Age']) | |
print("There are " + str(len(outliers)) + " Outliers. The maximum outlier value is " + str(outliers.max()) + " and the minimum outlier value is " + str(outliers.min())) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment