<SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
 Compare Climate Scenarios
1. Preliminaries
Step1:  2. Load the data
We have a function that pulls the data that we chose in the UI directly into the program 
using the container that we're connected to by docker-compose
Step2:  Replace the argument below with the unique ID of the dataset that you've chosen in the web UI.
Step3:  3. Examine the data
Step4:  4. Graph the data
<ASSISTANT_TASK:>
Python Code:
%matplotlib inline
import numpy as np
import pandas as pd
import urllib2
import matplotlib.pyplot as plt
import matplotlib
matplotlib.style.use('ggplot')
plt.rcParams['figure.figsize'] = (10.0, 8.0)
Explanation: Compare Climate Scenarios
1. Preliminaries
End of explanation
def load_data(unique_id):
    data = pd.read_csv(urllib2.urlopen("http://opennex/dataset/%s/data.csv" % (unique_id)))
    for col in ['Model', 'Scenario', 'Variable']:
        data[col] = data[col].astype('category')
    data['Date'] = data['Date'].astype('datetime64')
    data['Temperature'] = data['Value'] - 273.15
    return data
Explanation: 2. Load the data
We have a function that pulls the data that we chose in the UI directly into the program 
using the container that we're connected to by docker-compose
End of explanation
data = load_data("Ky3KN")
Explanation: Replace the argument below with the unique ID of the dataset that you've chosen in the web UI.
End of explanation
data.shape
data.apply(lambda x: [x.unique()])
Explanation: 3. Examine the data
End of explanation
colors = {'historical':'black', 'rcp45':'green', 'rcp85':'red'}
def do_graph(df):
    model = df.loc[1,'Model']
    df['Month'] = df['Date'].map(lambda d: "%d-%02d-01" % (d.year, d.month)).astype('datetime64')
    by_month = df.groupby(['Month', 'Scenario']).aggregate(np.mean).reset_index()
    by_month['Year'] = by_month['Month'].map(lambda d: "%d-01-01" % (d.year)).astype('datetime64')
    by_year = by_month.groupby(['Year', 'Scenario']).aggregate(max).loc[:,['Temperature']]
    groups = by_year.reset_index().set_index('Year').groupby('Scenario')
    for key, grp in groups:
        plt.plot(grp.index, grp['Temperature'], color=colors[key], label=key)
    plt.legend(loc='best')
    plt.title("Maximum mean temperature for warmest month using model %s" % (model))
    plt.xlabel("Year")
    plt.ylabel("Temperature (Celsius)")
    plt.show()
do_graph(data)
Explanation: 4. Graph the data
End of explanation
<END_TASK>