Created
August 22, 2020 18:27
-
-
Save JamesIgoe/6af2553fcb17a46b00da33e14b6d733e to your computer and use it in GitHub Desktop.
Correlation Filter: Creates a correlation matrix from a data frame. filters it for upper and lower bounds fo correlation, and then flattens it
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
#requires pandas and numpy | |
def corrFilter(x: pd.DataFrame, bound: float): | |
xCorr = x.corr() | |
xFiltered = xCorr[((xCorr >= bound) | (xCorr <= -bound)) & (xCorr !=1.000)] | |
xFlattened = xFiltered.unstack().sort_values().drop_duplicates() | |
return xFlattened |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment