Skip to content

Instantly share code, notes, and snippets.

@ostwalprasad
Created March 20, 2020 09:55
Show Gist options
  • Save ostwalprasad/f4f3de7d9bdae087b3b5cefb74110e23 to your computer and use it in GitHub Desktop.
Save ostwalprasad/f4f3de7d9bdae087b3b5cefb74110e23 to your computer and use it in GitHub Desktop.

Revisions

  1. ostwalprasad created this gist Mar 20, 2020.
    7 changes: 7 additions & 0 deletions cov.py
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,7 @@
    import numpy as np
    import pandas as pd

    df = YOUR_DATAFRAME
    ones = np.ones([df_shape[0],df_shape[0]])
    dev_mat = df - (ones @ df)/df_shape[0]
    cov_mat = (dev_mat.T @ dev_mat) / df_shape[0]