Skip to content

Instantly share code, notes, and snippets.

View twiecki's full-sized avatar

Thomas Wiecki twiecki

View GitHub Profile
{
"metadata": {
"name": "csv_conversion"
},
"nbformat": 3,
"nbformat_minor": 0,
"worksheets": [
{
"cells": [
{
{
"metadata": {
"name": "analysis_dbs"
},
"nbformat": 3,
"nbformat_minor": 0,
"worksheets": [
{
"cells": [
{
@twiecki
twiecki / gist:5438155
Created April 22, 2013 20:19
Clustering analysis of "Individual differences, aging, and IQ in two-choice tasks"
This file has been truncated, but you can view the full file.
{
"metadata": {
"name": "analyze_ratcliff"
},
"nbformat": 3,
"nbformat_minor": 0,
"worksheets": [
{
"cells": [
{
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
{
"metadata": {
"name": ""
},
"nbformat": 3,
"nbformat_minor": 0,
"worksheets": [
{
"cells": [
{
{
"metadata": {
"name": ""
},
"nbformat": 3,
"nbformat_minor": 0,
"worksheets": [
{
"cells": [
{
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
def initialize(context):
fetch_csv('URL',
date_format='%d/%m/%y',
universe_func=my_universe)
def my_universe(context, fetcher_data):
my_stocks = set(fetcher_data['sid'])
# log the size of the universe for debugging
context.count = len(my_stocks)
@twiecki
twiecki / custom_rolling.py
Created July 11, 2016 13:43
Rolling window and rolling apply with flexible lookback and resample behavior that also support parallelism.
import pandas as pd
from pandas.tseries.offsets import *
def rolling_window(data, resample='1BM', lookback=12 * BMonthEnd()):
dts = data.resample(resample).index
if lookback == 'aggregate':
for dt in dts:
yield data.loc[:dt]
else: