<SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
 Pandas
If you've never used pandas before, it's amazingly useful, and at times frustrating.
Recommended links
Step1:  Note
Using cleaned data from Data Cleaning Notebook. See Notebook for details.
Step2:  Notebook Extensions -- qgrid
<ASSISTANT_TASK:>
Python Code:
from __future__ import absolute_import, division, print_function
%matplotlib inline
import matplotlib.pyplot as plt
import seaborn as sns
sns.set_context('poster')
# sns.set_style('whitegrid') 
sns.set_style('darkgrid') 
plt.rcParams['figure.figsize'] = 12, 8  # plotsize 
import numpy as np
import pandas as pd
from pandas.tools.plotting import scatter_matrix
from sklearn.datasets import load_boston
Explanation: Pandas
If you've never used pandas before, it's amazingly useful, and at times frustrating.
Recommended links: 
http://pandas.pydata.org/pandas-docs/stable/gotchas.html
https://github.com/dwhitena/blog-content/blob/master/python_pitfalls/Python-Pitfalls.ipynb
http://pandas.pydata.org/pandas-docs/stable/cookbook.html
Read through this full series of excellent blog posts by Tom Augspurger.
High level tip
try to represent data in the proper format
floats as floats; ints as ints; etc. 
Especially if you have dates, or timestamps, or datetimestamps, keep them in that format. 
This pdf Tidy Data by Hadley Wickham is an excellent read with a lot that relates to data analysis in any language.
End of explanation
df = pd.read_csv("../data/coal_prod_cleaned.csv")
Explanation: Note
Using cleaned data from Data Cleaning Notebook. See Notebook for details.
End of explanation
!conda install qgrid -y
# Check out http://nbviewer.ipython.org/github/quantopian/qgrid/blob/master/qgrid_demo.ipynb for more (including demo)
import qgrid # Put imports at the top
qgrid.nbinstall(overwrite=True)
df.head()
qgrid.show_grid(df[['MSHA_ID', 'Year', 'Mine_Name', 'Mine_State', 'Mine_County']], remote_js=True)
%matplotlib inline
%matplotlib notebook
sns.set_context('poster')
sns.set_style('darkgrid')
plt.rcParams['figure.figsize'] = 12, 8  # plotsize 
import mpld3
mpld3.enable_notebook()
mpld3.disable_notebook()
plt.scatter(df.Average_Employees, 
            df.Labor_Hours)
plt.xlabel("Number of Employees")
plt.ylabel("Total Hours Worked");
colors = sns.color_palette(n_colors=5)
color_dict = {key: value for key, value in zip(sorted(df.Year.unique()), colors)}
color_dict
for year in sorted(df.Year.unique()[[0, 2, -1]]):
    plt.scatter(df[df.Year == year].Labor_Hours,
                df[df.Year == year].Production_short_tons, 
                c=color_dict[year],
                s=50,
                label=year,
               )
plt.xlabel("Total Hours Worked")
plt.ylabel("Total Amount Produced")
plt.legend()
plt.savefig("ex1.png")
import matplotlib as mpl
mpl.style.use('bmh')
plt.style.available
for year in sorted(df.Year.unique()[[0, 2, -1]]):
    plt.scatter(df[df.Year == year].Labor_Hours,
                df[df.Year == year].Production_short_tons, 
                c=color_dict[year],
                s=50,
                label=year,
               )
plt.xlabel("Total Hours Worked")
plt.ylabel("Total Amount Produced")
plt.legend()
# plt.savefig("ex1.png")
df_dict = load_boston()
features = pd.DataFrame(data=df_dict.data, columns = df_dict.feature_names)
target = pd.DataFrame(data=df_dict.target, columns = ['MEDV'])
df = pd.concat([features, target], axis=1)
df.head()
# Target variable
fig, ax = plt.subplots(figsize=(10,8))
sns.distplot(df.MEDV, ax=ax, rug=True, hist=False)
fig, ax = plt.subplots(figsize=(10,7))
sns.kdeplot(df.LSTAT,
            df.MEDV,
            ax=ax)
fig, ax = plt.subplots(figsize=(10, 10))
scatter_matrix(df[['MEDV', 'LSTAT', 'CRIM', 'RM', 'NOX', 'DIS']], alpha=0.2, diagonal='hist', ax=ax);
Explanation: Notebook Extensions -- qgrid
End of explanation
<END_TASK>