python - 从第二列开始循环

标签 python quantopian

我正在循环列,但在第一列上不断收到错误,因为它似乎是日期时间。有没有办法让我在第二列开始 for 循环。这是使用 Quantopian 基本数据

for column in Fundamentals.columns:  
    #print(column)  
    start=1+start  
    next = str(column)   

    Prev=Previous(inputs=[column],window_length=window_length)
    Curr=column.latest

    diff=Prev-Curr

    if(diff>0):
        pipe.add(column.latest,next)  

        if start>10:  
            break  
        #print('{}:{},').format(next,column)

最佳答案

由于您已经在列上循环,因此您可以简单地使用索引 [1:] 作为

for column in Fundamentals.columns[1:]:  

跳过第一列并从第二列开始。

关于python - 从第二列开始循环,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/53874575/

相关文章:

python - 在 zipline 上运行回测时如何解决 AssertionError

Python Zipline 离线测试

python - 带有 mpz/mpfr 值的 numpy 数组

python - 使用 numpy,是否可以根据其他矩阵定义矩阵?

python - TensorFlow 数据集的意外维度

python - numpy 数组大小的困惑

python -- 在分配给 sys.modules 时检查模块名称是否有效