<SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
 Byte 2 Google Data Labs Notebook
This is an example notebook that illustrates use of Pandas and Seaborn to load and explore data from a Fusion Table.
We start by loading required libraries
Step1:  Load Data from a Fusion Table
Here we download the data and store it in a local JSON file for easier access.
Step2:  Load JSON Data into a Dataframe
Now that we have the JSON file locally, we will load it into a Pandas dataframe for easy access.
Step3:  Select and Clean Up Data
Pandas makes it easy to access different columns and rows in the dataframe. Here we create a new data frame containing only Latitude and Longitude.
Step4:  Now we can quickly convert both columns to numeric and remove values that could not be converted (NaN). It is all done on one line!
Step5:  Visualize Data
We can now use Seaborn to quickly plot the data from the data frame. In this example we quickly compare the two variables in a pairplot.
<ASSISTANT_TASK:>
Python Code:
# Import libraries.
import csv
import httplib2
from apiclient.discovery import build
import urllib
import json
import numpy as np
import pandas as pd
import matplotlib as mpl
import matplotlib.pyplot as plt
import seaborn as sns
Explanation: Byte 2 Google Data Labs Notebook
This is an example notebook that illustrates use of Pandas and Seaborn to load and explore data from a Fusion Table.
We start by loading required libraries:
End of explanation
# This API key is provided by google as described in the tutorial
API_KEY = 'AIzaSyCuKKwcT5mUYZP_Q-heqCPjvdWyacRuX00'
# This is the table id for the fusion table
TABLE_ID = '1ymz3EtGdi4qKGMl5AxEFXtTlgk3tKi8iCpjTzvM'
# open the data stored in a file called "data.json"
try:
    fp = open("data.json")
    response = json.load(fp)
# but if that file does not exist, download the data from fusiontables
except IOError:
    service = build('fusiontables', 'v1', developerKey=API_KEY)
    query = "SELECT * FROM " + TABLE_ID + " WHERE  AnimalType = 'DOG'"
    response = service.query().sql(sql=query).execute()
    fp = open("data.json", "w")
    json.dump(response, fp)
# Check how many rows we have.
print len(response['rows'])
Explanation: Load Data from a Fusion Table
Here we download the data and store it in a local JSON file for easier access.
End of explanation
data_df = pd.DataFrame(response[u'rows'], columns = response[u'columns'])
# Show a few rows.
data_df.head()
Explanation: Load JSON Data into a Dataframe
Now that we have the JSON file locally, we will load it into a Pandas dataframe for easy access.
End of explanation
lat_lon_df = data_df[['Latitude', 'Longitude']]
lat_lon_df.head()
Explanation: Select and Clean Up Data
Pandas makes it easy to access different columns and rows in the dataframe. Here we create a new data frame containing only Latitude and Longitude.
End of explanation
lat_lon_df = lat_lon_df.apply(lambda x: pd.to_numeric(x, errors='ignore')).dropna()
Explanation: Now we can quickly convert both columns to numeric and remove values that could not be converted (NaN). It is all done on one line!
End of explanation
sns.pairplot(lat_lon_df)
Explanation: Visualize Data
We can now use Seaborn to quickly plot the data from the data frame. In this example we quickly compare the two variables in a pairplot.
End of explanation
<END_TASK>