Skip to content

Instantly share code, notes, and snippets.

@ShrashtiSinghal
Last active August 6, 2020 17:46
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ShrashtiSinghal/0eb73ab620be685575d7017ff3ff1e65 to your computer and use it in GitHub Desktop.
Save ShrashtiSinghal/0eb73ab620be685575d7017ff3ff1e65 to your computer and use it in GitHub Desktop.
#Find Percentage of outliers in every column
for k, v in data.items():
q1 = v.quantile(0.25)
q3 = v.quantile(0.75)
IQR = q3 - q1
v_col = v[(v <= q1 - 1.5 * IQR) | (v >= q3 + 1.5 * IQR)]
percentage = np.shape(v_col)[0] * 100.0 / np.shape(data)[0]
print("Column %s outliers = %.2f%%" % (k, percentage))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment