Skip to content

Instantly share code, notes, and snippets.

hamx0r /
Last active Dec 17, 2018 — forked from linar-jether/
Grafana python 3 datasource - using pandas for timeseries and table data. inspired by and compatible with the simple json datasource
Uses `flask_restful` and creates a Blueprint to be used by a parent project (ie a larger API project where
`/grafana/` endpoints are used by Grafana's SimpleJson plugin)
from flask import Flask, request, jsonify, json, abort, Blueprint
from flask_cors import CORS, cross_origin
import flask_restful
import pandas as pd
View gist:b851531d8546565c23deab926ee6867e
Copyright 2011 Martin Hawksey
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
Unless required by applicable law or agreed to in writing, software
hamx0r /
Last active Mar 12, 2018 — forked from alexalemi/
Python Welford Algorithm
import math
class Welford(object):
""" Implements Welford's algorithm for computing a running mean
and standard deviation as described at:
can take single values or iterables
mean - returns the mean
hamx0r /
Last active Feb 4, 2018
Zipline Data Source which pulls from Memecache
""" MemcacheDataSource Class to pull data from memcache on demand for a simulation, minimizing data load time for a
simulation, and allowing Memcached stock data to be shared by multiple parallel simulations.
The MemCacheData class implements methods to act in compliance with the `zipline.algorithm.TradingAlgorithm.sources`
This means implementing the following methods (with line numbers per v0.9.0 linked above):
* `sids` (Line 562)
* iterator (or generator) methods (439) like:
- '__iter__'