Created
September 13, 2019 16:22
-
-
Save KalebNyquist/4403df5d1785436635d5e75ef7d58df5 to your computer and use it in GitHub Desktop.
Strange Zeroes #EDA
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
import pandas as pd | |
import numpy as np | |
def strange_zeroes(dataset, drop_columns = None, zero = 0): | |
"""Exploratory Data Analysis function that looks to see if there is any correlation between '0' values occurerence, | |
which would suggest a relationship between the instruments used and their non-detection of a value.""" | |
# Find all zeroes (can be altered to including other common missing / non-response values as well) | |
zeroes = (dataset == zero) | |
# Cleaning Code (Optional) | |
if drop_columns != None: | |
zeroes = zeroes.drop(drop_columns, axis=1) | |
# SOURCE: https://stackoverflow.com/a/50703596 | |
corr = zeroes.corr() | |
return corr.style.background_gradient(cmap='coolwarm') # NOTE: 'RdBu_r' & 'BrBG' are other good diverging colormaps |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment