<SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
 Global Surface Temperature
This example uses historical data since 1880 on average global surface temperature changes from NASA's GISS Surface Temperature Analysis (GISTEMP) (original file) That site has lots of other data sets in csv format, too.
Click the "play" icon or press shift+enter to execute each cell.
Step1:  Importing a data set
This next cell may take a little while to run if it's grabbing a pretty big data set. The cell label to the left will look like "In [*]" while it's still thinking and "In [2]" when it's finished.
Step2:  We can view the first few rows of the file we just imported.
Step3:  Plotting the data
Step4:  Edit and re-plot
If you like Randall Monroe's webcomic XKCD as much as I do, you can make your plots look like his hand-drawn ones. Thanks to Jake VanderPlas for sorting that out.
<ASSISTANT_TASK:>
Python Code:
# import the software packages needed
import pandas as pd
import numpy as np
%matplotlib inline
import matplotlib as mpl
import matplotlib.pyplot as plt
inline_rc = dict(mpl.rcParams)
Explanation: Global Surface Temperature
This example uses historical data since 1880 on average global surface temperature changes from NASA's GISS Surface Temperature Analysis (GISTEMP) (original file) That site has lots of other data sets in csv format, too.
Click the "play" icon or press shift+enter to execute each cell.
End of explanation
# Combined land and ocean temperature averages (LOTI: Land Ocean Temperature Index)
data1 = pd.read_csv('http://github.com/adamlamee/CODINGinK12-data/raw/master/LOTI.csv', header=1).replace(to_replace="***", value=np.NaN)
data_LOTI = data1.apply(lambda x: pd.to_numeric(x, errors='ignore'))
# Only land temperature averages
data2 = pd.read_csv('http://github.com/adamlamee/CODINGinK12-data/raw/master/LAND.csv', header=1).replace(to_replace="***", value=np.NaN)
data_LAND = data2.apply(lambda x: pd.to_numeric(x, errors='ignore'))
Explanation: Importing a data set
This next cell may take a little while to run if it's grabbing a pretty big data set. The cell label to the left will look like "In [*]" while it's still thinking and "In [2]" when it's finished.
End of explanation
# The .head(n) command displays the first n rows of the file.
data_LAND.head(5)
Explanation: We can view the first few rows of the file we just imported.
End of explanation
x1 = data_LOTI.Year
y1 = data_LOTI.JanDec
# plt.plot() makes a line graph, by default
fig = plt.figure(figsize=(10, 5))
plt.plot(x1, y1)
plt.title('Average land an docean temperature readings')
plt.xlabel('Year')
plt.ylabel('Percent temp change')
x2 = data_LAND.Year
y2 = data_LAND.JanDec
# plt.plot() makes a line graph, by default
fig = plt.figure(figsize=(10, 5))
plt.plot(x2, y2)
plt.title('Land temperature readings')
plt.xlabel('Year')
plt.ylabel('Percent temp change')
# Wow, this needs a title and axis labels!
fig = plt.figure(figsize=(10, 5))
plt.plot(x1, y1, label="Land and Ocean")
plt.plot(x2, y2, label="Land only")
plt.legend()
plt.show()
Explanation: Plotting the data
End of explanation
plt.xkcd()
fig = plt.figure(figsize=(10, 5))
plt.plot(x1, y1)
# to make normal plots again
mpl.rcParams.update(inline_rc)
Explanation: Edit and re-plot
If you like Randall Monroe's webcomic XKCD as much as I do, you can make your plots look like his hand-drawn ones. Thanks to Jake VanderPlas for sorting that out.
End of explanation
<END_TASK>