Skip to content

Instantly share code, notes, and snippets.

@julian-west
Created September 7, 2019 16:58
Show Gist options
  • Save julian-west/b66319a742d8b8a7c874c19d6ac49050 to your computer and use it in GitHub Desktop.
Save julian-west/b66319a742d8b8a7c874c19d6ac49050 to your computer and use it in GitHub Desktop.
#convert matrix to list of edges and rename the columns
edges = correlation_matrix.stack().reset_index()
edges.columns = ['asset_1','asset_2','correlation']
#remove self correlations
edges = edges.loc[edges['asset_1'] != edges['asset_2']].copy()
#show the first 5 rows of the edge list dataframe.
edges.head()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment