Skip to content

Instantly share code, notes, and snippets.

@metasyn
Created May 11, 2016 11:39
Show Gist options
  • Select an option

  • Save metasyn/787d2988bd142f5325cbbc08633e22b9 to your computer and use it in GitHub Desktop.

Select an option

Save metasyn/787d2988bd142f5325cbbc08633e22b9 to your computer and use it in GitHub Desktop.
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