python

remove outliers

def outliers(column):
    Q1, Q3 = np.percentile(column, [25, 75])
    IQR = Q3 - Q1
    lower_range = Q1 - (1.5 * IQR)
    upper_range = Q3 + (1.5 * IQR)
    return lower_range, upper_range

outliers(df['yearly_salary'])
Output
(-2750.0, 151250.0)

# remove outliers from a single column

Was this helpful?