Quantopian's community platform is shutting down. Please read this post for more information and download your code.
Back to Community
Hello Pipeline API

Hello Forum,
I am new to Quantopian. I have been trying to use pipeline API and trying to follow the tutorial to build some research algorithms.
I have notices that pipeline.head(5) doesnt work any more but all the tutorial material on the quantopian website seems to use them.

Any advice on what could be issue - this is what i get as error:
results = make_pipeline()
print results.head()

AttributeErrorTraceback (most recent call last)
in ()
----> 1 print results.head()

AttributeError: 'Pipeline' object has no attribute 'head'

Please let me know if i have missed something.

Regards
Tushar

1 response

First off, welcome to Quantopian!

Look again at the tutorials. Look especially at lesson 2 "Creating a Pipeline" (https://www.quantopian.com/tutorials/pipeline#lesson2). There are two distinct steps in using a pipeline 1) define and instantiate it and 2) run the pipeline. You are missing step 2.

One first creates a pipeline. That's what is done in the following statements

from quantopian.pipeline import Pipeline

def make_pipeline():  
    return Pipeline()

my_pipe = make_pipeline()

One now has instantiated a pipeline object and created a reference to it 'my_pipe'. The most important thing to understand about pipelines, and the DataSets they use, is that they do not hold actual data. A pipeline simply defines how to fetch the data and the computations one wishes to perform. That is why the following doesn't work

results = make_pipeline()  
print results.head()

The pipeline object isn't a dataframe. It's not the results yet. It doesn't have any data to print. The output of the make_pipeline method is a pipeline object.

So, the second step is to execute run_pipeline. The output of that method is a dataframe which does hold the data. That will be the results.

from quantopian.research import run_pipeline

result = run_pipeline(my_pipe, '2015-05-05', '2015-05-05')

result.head(5)

The first step of creating and instantiating a pipeline only needs to be done once. After that, step two, running the run_pipeline method, can be done as many times and across as many timeframes as desired. The lectures and associated notebooks should make this two step process clear but there are a number of post in the forums here which also help to explain the pipeline concept.

https://www.quantopian.com/posts/need-help-with-pipeline-just-a-beginner
https://www.quantopian.com/posts/pipeline-and-history-function

Hope that helps.

Disclaimer

The material on this website is provided for informational purposes only and does not constitute an offer to sell, a solicitation to buy, or a recommendation or endorsement for any security or strategy, nor does it constitute an offer to provide investment advisory services by Quantopian. In addition, the material offers no opinion with respect to the suitability of any security or specific investment. No information contained herein should be regarded as a suggestion to engage in or refrain from any investment-related course of action as none of Quantopian nor any of its affiliates is undertaking to provide investment advice, act as an adviser to any plan or entity subject to the Employee Retirement Income Security Act of 1974, as amended, individual retirement account or individual retirement annuity, or give advice in a fiduciary capacity with respect to the materials presented herein. If you are an individual retirement or other investor, contact your financial advisor or other fiduciary unrelated to Quantopian about whether any given investment idea, strategy, product or service described herein may be appropriate for your circumstances. All investments involve risk, including loss of principal. Quantopian makes no guarantees as to the accuracy or completeness of the views expressed in the website. The views are subject to change, and may have become unreliable for various reasons, including changes in market conditions or economic circumstances.