Created
May 11, 2016 11:39
-
-
Save metasyn/787d2988bd142f5325cbbc08633e22b9 to your computer and use it in GitHub Desktop.
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
| import exec_anaconda | |
| try: | |
| exec_anaconda.exec_anaconda() | |
| except Exception as e: | |
| import cexc | |
| cexc.abort(e) | |
| sys.exit(1) | |
| # Import this to get our "chunked" handler | |
| from cexc import BaseChunkHandler | |
| import pandas as pd | |
| class Handler(BaseChunkHandler): | |
| def handler(self, metadata, data): | |
| """Get covariance matrix from a pandas dataframe""" | |
| df = pd.DataFrame(data, dtype='float').cov() | |
| df['(field)'] = df.columns | |
| output = df.to_dict(orient='records') | |
| # return the data | |
| return({}, output) | |
| if __name__ == "__main__": | |
| Handler().run() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment