<jupyter_start><jupyter_text>This notebook plots NASA's Global Surface Temperature data, from 1880 to present. For more details on global surface temperature changes and trends, see https://data.giss.nasa.gov/gistemp/<jupyter_code>import requests
import io
import urllib3; urllib3.disable_warnings(urllib3.exceptions.InsecureRequestWarning)
import pandas as pd
import numpy as np
import matplotlib.pyplot as plt
%matplotlib inline<jupyter_output><empty_output><jupyter_text>1. Load the dataset Global Surface Temperature history dataset (1880-present) is currently (10/22/2017) available on NASA's web site.<jupyter_code>dataset = requests.get(url="https://data.giss.nasa.gov/gistemp/tabledata_v3/GLB.Ts+dSST.csv", verify=False).content 
dataset = io.StringIO(dataset.decode('utf8'))
data_df = pd.read_csv(dataset, skiprows=0, header=1)<jupyter_output><empty_output><jupyter_text>Note: If you are unable to download the data set (e. g. due to connectivity problems, or if the data disappears from NAS web site), the repo includes a cached local copy of the data (downloaded on 10/21/2017, from https://data.giss.nasa.gov/gistemp/tabledata_v3/GLB.Ts+dSST.csv).<jupyter_code># data_df = pd.read_csv("GLB.Ts+dSST.csv", skiprows=0, header=1)<jupyter_output><empty_output><jupyter_text>Raw Global Surface Temperture dataset:<jupyter_code>data_df<jupyter_output><empty_output><jupyter_text>2. Clean up the data<jupyter_code>data_df = data_df[:-1] # remove the current year (the data is still being collected)
data_df = data_df.drop(labels=['J-D', 'D-N', 'DJF', 'MAM', 'JJA', 'SON'], axis=1) # remove unnecessary columns
# Interpret monthly measurements as numeric / float32
months = list(data_df)[1:13]
data_df[months] = data_df[months].astype(np.float32)<jupyter_output><empty_output><jupyter_text>2. Compute the totals, for each year<jupyter_code>months = list(data_df)[1:13]
data_df["total"] = data_df[months].sum(axis=1)
trendline =  data_df["total"].rolling(8).mean()<jupyter_output><empty_output><jupyter_text>Cleaned up, computed data:<jupyter_code>data_df<jupyter_output><empty_output><jupyter_text>3. Plot Global Surface Temperature<jupyter_code>plt.plot(data_df["Year"], data_df["total"], label="yearly")
plt.plot(data_df["Year"], tl2, label='trend')
plt.grid(True)
plt.legend()
plt.title("Global Surface Temperature, 1880-present")<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.12848689771766694, 'fraction_numerical': 0.024091293322062553, 'mean_word_length': 7.865168539325842, 'pattern_counts': {'":': 0, '<': 33, '<?xml version=': 0, '>': 33, 'https://': 3, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 2, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '8', 'dir': 'jupyter-structured-clean-dedup', 'id': '418279', 'license': 'Unlicense', 'n_tokens_mistral': 899, 'n_tokens_neox': 833, 'n_words': 181, 'path': 'Global Surface Temperature Trend (1880-present).ipynb', 'repo_name': 'markmark206/GlobalSurfaceTemperatureChange', 'size': '2366'}