Reputation: 383
I'm trying to remove outliers falling in 2 ranges, but keep receiving errors. I've tried with the Boolean & and | characters, np.logical_or and np.logical_and, with a .any(), or .all() as well, to no avail. Could someone please advise what I'm doing wrong here? This is the boxplot that shows the outliers:
and here's the code I'm trying to use to filter out the outliers:
Thanks in advance for feedback.
Upvotes: 0
Views: 360
Reputation: 2013
As pointed out by the comments, you can compute the bitmask rm_filter
like so:
rm_filter = (df['RM'] >=7.75) | (df['RM'] <=4.75)
and should be able to remove those records like:
df_rm_outlier_rem = df[~rm_filter]
where the tilde ~ negates the filter.
Upvotes: 1