===============================================
Using Yahoo S&P 500 data with QGrid and Jupyter
===============================================

QGrid is a dataframe viewer for Jupyter Notebook.

In this tutorial, we'll use QGrid to display S&P 500 stock market data.

#. :ref:`Start Navigator <navigator-starting>`.

#. To install the QGrid and Pandas Datareader packages, follow the
   instructions in :ref:`navigator-install-package`.

#. To open a Jupyter Notebook, follow the instructions in :ref:`navigator-use-environment`.

#. Copy and paste the following code into the first cell:

   .. code-block:: python

      import qgrid
      import pandas as pd
      import pandas_datareader
      pd.set_option('display.max_rows', 8) # Prevents the grid from being too large
      from pandas_datareader.data import get_data_yahoo
      spy = get_data_yahoo(symbols='SPY', start=pd.Timestamp('2011-01-01'),
                     end=pd.Timestamp('2014-01-01'), adjust_price=True)
      spy

#. To run the code, in the menu bar, click Cell then select Run Cells, 
   or use the keyboard shortcut Ctrl-Enter.

   A Pandas DataFrame is created that contains the daily prices for the S&P 500 from
   1/1/2011--1/1/2014 and displays the first four and last four rows of the DataFrame.

   .. figure:: /img/navigator-tutorial06.png

      ..

   |

NOTE: The example code is taken from https://github.com/quantopian/qgrid and
http://nbviewer.jupyter.org/gist/TimShawver/b4bc80d1128407c56c9a .
