Created
October 9, 2015 07:28
-
-
Save dyerrington/dd6d75d432c15cc631cc to your computer and use it in GitHub Desktop.
Singular linear coefficients
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
def auto_coefficients(df): | |
sorted_coefs = list() | |
coefs = df.corr() | |
for row_index, row_values in enumerate(coefs.values): | |
for col_index, col_value in enumerate(row_values): | |
if coefs.columns[row_index] == coefs.columns[col_index]: | |
continue | |
sorted_coefs.append((coefs.columns[row_index], coefs.columns[col_index], col_value)) | |
return sorted(sorted_coefs, key=lambda values: values[2], reverse=True) | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment