Created
July 5, 2020 13:18
-
-
Save finlytics-hub/f6a1c47e802385b1d875b9ba58f6826b to your computer and use it in GitHub Desktop.
Practical demonstration of using IQR to drop outlier rows
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
# Calculate 1st and 3rd percentiles, and IQR | |
Q1 = X_train.quantile(0.25) | |
Q3 = X_train.quantile(0.75) | |
IQR = Q3 - Q1 | |
# Filter out the rows that fall outside the 1.5 threshold in each column | |
X_train_new = X_train[~((X_train < (Q1 - 1.5 * IQR)) | (X_train > (Q3 + 1.5 * IQR))).any(axis=1)] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment