text_html_output_1.png
from collections import Counter

import numpy as np # linear algebra

import pandas as pd # data processing, CSV file I/O (e.g. pd.read_csv)

suicide_rates = pd.read_csv('/kaggle/input/suicide-rates-overview-1985-to-2016/master.csv')

suicide_rates.columns

def detect_outliers(df, columnNames):
    outlier_indices = []
    for c in columnNames:
        Q1 = np.percentile(df[c], 25)
        Q3 = np.percentile(df[c], 75)
        IQR = Q3 - Q1
        outlier_step = IQR * 1.5
        outlier_list_col = df[(df[c] < Q1 - outlier_step) | (df[c] > Q3 + outlier_step)].index
        outlier_indices.extend(outlier_list_col)
    outlier_indices = Counter(outlier_indices)
    multiple_outliers = list((i for i, v in outlier_indices.items() if v > 1))
    return multiple_outliers

suicide_rates.loc[detect_outliers(suicide_rates, ['population', 'gdp_per_capita ($)', 'suicides/100k pop'])]