Quantopian's community platform is shutting down. Please read this post for more information and download your code.
Back to Community
help with build error, Pandas pivot_table

For the code below, I'm getting a Build Error:

14 Error Runtime exception: TypeError: pivot_table() got an unexpected keyword argument 'index'

What am I doing wrong?


import pandas as pd

def initialize(context):  
    context.spy = sid(8554)

def handle_data(context, data):  
    prices = history(3900,'1m','price',ffill=False)  
    prices['date'] = prices.index.map(lambda x: x.date())  
    prices['time'] = prices.index.map(lambda x: x.hour+x.minute/60.0)  
    prices_pivot = pd.pivot_table(prices, context.spy, index=prices['date'], columns=prices['time'])  
    print prices_pivot  
1 response

This works (I think), although it seems to run very slowly. --Grant

import pandas as pd  
from pytz import timezone

def initialize(context):  
    context.spy = sid(8554)

def handle_data(context, data):  
    prices = history(3900,'1m','price',ffill=False)  
    prices['date'] = prices.index.date  
    prices['time'] = prices.index.tz_convert(timezone('US/Eastern')).time  
    prices_pivot = prices.pivot(index='date', columns='time')  
    print prices_pivot