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

Hi, I just started working with the Pipeline tutorial and have a question on output. When I run this notebook the output only shows 5 securities at a time. Is there a way to show more or export the list?

For instance, if I change this variable "over_leverage" it will reduce/expand the list. I'd like to see the companies included in the list when it is larger than 5.

over_leverage > 2 is 1 company

over_leverage > 1.5 is 10 companies

over_leverage > 1.25 is 36 companies

over_leverage > 1 is 152 companies

Thanks!

3 responses

Changing:

result.head()

to

result.head(10)

or

result.head(25)

or

result.head(50)

etc. seems to work

Can't really export a list from a notebook and this is intentional. The quantopian data providers don't allow for redistribution of their data (otherwise you could export all the morningstar data every day and post it somewhere). However, it does work pretty well to highlight the cells in a returned dataframe, copy, and then paste them into a spreadsheet. I use Mac Numbers and it formats fine. I assume Excel would do the same.

If you want to see more than 5 records at a time either 1) include the number of records you want. For example '.head(20)' returns the top 20 rows. The '.head' method defaults to 5 if no number is given. Or 2) don't use the head method. Instead of 'my_data_frame.head(20)' simply type 'my_data_frame'. That will print the whole dataframe up to some limit. If there are too many rows it prints the first AND the last bunch of rows. Good when looking at sorted lists to see largest and smallest values at once.

Rather than filtering by 'over_leverage' you may want to remove that filter and add another factor called 'leverage'. That way the resulting pipeline output dataframe will have a column with the actual leverage value. You can then sort by that value and see what companies are being returned.

I've attached your notebook with some of those changes. I didn't comment it but you should get the picture.

As an aside, I'm a fan of the '.query' method (http://pandas.pydata.org/pandas-docs/stable/generated/pandas.DataFrame.query.html). Statements like this are very readable in my mind...

result.query('leverage > 1 & leverage < 1.1').sort_values('leverage', ascending = False)

A nice way to slice and dice the dataframe.

Forgot to attach the notebook....