-
-
Save monkey-codes/1aeb07a7bd498ceb12d6da58fdf3b3d0 to your computer and use it in GitHub Desktop.
How to get do a rank correlation using python
This file contains hidden or 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
| #df - pandas dataFrame | |
| fromfrom scipy.clusterscipy.cl import hierarchy as hc | |
| corr = np.round(scipy.stats.spearmanr(df).correlation, 4) | |
| corr_condensed = hc.distance.squareform(1-corr) | |
| z = hc.linkage(corr_condensed, method='average') | |
| fig = plt.figure(figsize=(16,10)) | |
| dendrogram = hc.dendrogram(z, labels=df_keep.columns, orientation='left', leaf_font_size=16) | |
| plt.show() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment