<SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
 qgrid - SlickGrid in IPython notebook
Qgrid is an IPython extension which uses a javascript library called SlickGrid to render pandas DataFrames within an IPython notebook.  It's being developed for use in Quantopian's hosted research environment, and this notebook demonstrates the current state of the project.
Overview
SlickGrid is an an advanced javascript grid which allows users to scroll, sort, 
and filter hundreds of thousands of rows with extreme responsiveness.  
Pandas is a powerful data analysis / manipulation library for Python, and DataFrames are the primary way of storing and manipulating two-dimensional data in pandas.
Qgrid renders pandas DataFrames as SlickGrids, which enables users to explore the entire contents of a DataFrame using intuitive sorting and filtering controls.  It's designed to be used within IPython notebook, and it's also fully functional when rendered in nbviewer.
Installation using 'pip install'
Qgrid is a python module so you can install it using pip
Step1:  Prepare non-python dependencies by calling "nbinstall"
Step2:  Set default options by calling "set_defaults" (optional)
Step3:  Demo 1 - Rendering a DataFrame returned by Yahoo Finance
First, lets create a sample DataFrame using pandas 'get_data_yahoo' function
Step4:  BEFORE - Here's IPython's default representation of our 'spy' DataFrame
Step5:  AFTER - Here's the same 'spy' DataFrame being rendered as a qgrid
Step6:  Configuring your grid using SlickGrid options
By default, columns are stretched to fill the full width of the grid area.  That doesn't work if you have hundreds of columns, so you can change this behavior by using the forceFitColumns and defaultColumnWidth SlickGrid options.  See https
Step7:  Demo 2 - Rendering a sample DataFrame that includes a MultiIndex
Now let's create another DataFrame, but let's give it a MultiIndex this time
Step8:  BEFORE - Here's IPython's default representation of our 'multi_index_df' DataFrame
Step9:  AFTER - Here's the same 'multi_index_df' DataFrame being rendered as a qgrid
Step10:  API & Usage
API documentation is hosted on readthedocs
Step11:  Prepare non-python dependencies by calling 'nbinstall'
<ASSISTANT_TASK:>
Python Code:
import qgrid
Explanation: qgrid - SlickGrid in IPython notebook
Qgrid is an IPython extension which uses a javascript library called SlickGrid to render pandas DataFrames within an IPython notebook.  It's being developed for use in Quantopian's hosted research environment, and this notebook demonstrates the current state of the project.
Overview
SlickGrid is an an advanced javascript grid which allows users to scroll, sort, 
and filter hundreds of thousands of rows with extreme responsiveness.  
Pandas is a powerful data analysis / manipulation library for Python, and DataFrames are the primary way of storing and manipulating two-dimensional data in pandas.
Qgrid renders pandas DataFrames as SlickGrids, which enables users to explore the entire contents of a DataFrame using intuitive sorting and filtering controls.  It's designed to be used within IPython notebook, and it's also fully functional when rendered in nbviewer.
Installation using 'pip install'
Qgrid is a python module so you can install it using pip:
pip install git+https://github.com/quantopian/qgrid
Import it into your namespace like you would for any other python module:
End of explanation
qgrid.nbinstall(overwrite=True)  # copies javascript dependencies to your /nbextensions folder 
Explanation: Prepare non-python dependencies by calling "nbinstall":
End of explanation
qgrid.set_defaults(remote_js=True, precision=4)
Explanation: Set default options by calling "set_defaults" (optional):
End of explanation
import pandas as pd
import numpy as np
randn = np.random.randn
pd.set_option('display.max_rows', 8)
from pandas.io.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,
)
Explanation: Demo 1 - Rendering a DataFrame returned by Yahoo Finance
First, lets create a sample DataFrame using pandas 'get_data_yahoo' function:
End of explanation
spy
Explanation: BEFORE - Here's IPython's default representation of our 'spy' DataFrame:
End of explanation
qgrid.show_grid(spy)
Explanation: AFTER - Here's the same 'spy' DataFrame being rendered as a qgrid:
End of explanation
qgrid.show_grid(spy, grid_options={'forceFitColumns': False, 'defaultColumnWidth': 200})
Explanation: Configuring your grid using SlickGrid options
By default, columns are stretched to fill the full width of the grid area.  That doesn't work if you have hundreds of columns, so you can change this behavior by using the forceFitColumns and defaultColumnWidth SlickGrid options.  See https://github.com/mleibman/SlickGrid/wiki/Grid-Options for the full list of SlickGrid options that you can configure:
End of explanation
tuples = list(zip(*[['bar', 'bar', 'baz', 'baz', 'foo', 'foo', 'qux', 'qux'],
          ['one', 'two', 'one', 'two', 'one', 'two', 'one', 'two']]))
index = pd.MultiIndex.from_tuples(tuples, names=['first', 'second'])
multi_index_df = pd.DataFrame(randn(8, 2), index=index, columns=['A', 'B'])
Explanation: Demo 2 - Rendering a sample DataFrame that includes a MultiIndex
Now let's create another DataFrame, but let's give it a MultiIndex this time:
End of explanation
multi_index_df
Explanation: BEFORE - Here's IPython's default representation of our 'multi_index_df' DataFrame:
End of explanation
qgrid.show_grid(multi_index_df)
Explanation: AFTER - Here's the same 'multi_index_df' DataFrame being rendered as a qgrid:
End of explanation
import qgrid
Explanation: API & Usage
API documentation is hosted on readthedocs: http://qgrid.readthedocs.org/en/latest/
The API documentation can also be accessed via the "?" operator in IPython.  To use the "?" operator, type the name of the function followed by "?" to see the documentation for that function, like this:
```
qgrid.nbinstall?
qgrid.show_grid?
qgrid.set_defaults?
qgrid.set_grid_options?
```
Running from source using 'git clone'
Use git to clone the qgrid repository to your hard drive
git clone git@github.com:quantopian/qgrid.git
Set the root folder of your qgrid repository to be the working directory for your IPython notebook server
This is an easy way to get qgrid to run directly from the source code.  IPython notebook will look in it's working directory for modules to load, so qgrid will immediately become available for importing.
ipython notebook --notebook-dir=~/path/to/qgrid/repo
It's not always convenient to use the qgrid repository as your working directory for IPython noteboook, so I often create symbolic-links from qgrid's source code into the "/nbextensions" and "/extensions" folders under my IPython directory.
Import it into your namespace like you would for any other python module:
End of explanation
qgrid.nbinstall(overwrite=True)  # use overwrite=True to keep your /nbextensions folder up to date during development
Explanation: Prepare non-python dependencies by calling 'nbinstall':
End of explanation
<END_TASK>