Quantopian AttributeError:'numpy.ndarray'对象在计算表= ty.DataFrame(index = assets)中没有属性'DataFrame'用户算法:29

时间:2018-11-29 09:37:15

标签: python quantopian

我正在尝试将Morningstar的总收益值实现到我的算法中,但是会引发此错误,这是怎么回事?

from quantopian.algorithm import attach_pipeline, pipeline_output
from quantopian.pipeline import Pipeline
from quantopian.pipeline import CustomFactor
from quantopian.pipeline.data.builtin import USEquityPricing
from quantopian.pipeline.data import morningstar

import pandas as pd
import numpy as np


class Totalyield(CustomFactor):   
    # Pre-declare inputs and window_length
    #total yield = dividend yield + buyback yield
    inputs = [morningstar.valuation_ratios.total_yield] 
    window_length = 1


    def compute(self, today, assets, out, ty):
        table = ty.DataFrame(index=assets)
        table ["ty"] = ty[-1]        
        out[:] = table.fillna(table.max()).mean(axis=1)

运行时错误

AttributeError: 'numpy.ndarray' object has no attribute 'DataFrame'
USER ALGORITHM:29, in compute
table = ty.DataFrame(index=assets)

0 个答案:

没有答案