Skip to content

Instantly share code, notes, and snippets.

@dyerrington
Created October 9, 2015 07:28
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 dyerrington/dd6d75d432c15cc631cc to your computer and use it in GitHub Desktop.
Save dyerrington/dd6d75d432c15cc631cc to your computer and use it in GitHub Desktop.
Singular linear coefficients
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