{ "cells": [ { "cell_type": "markdown", "metadata": {}, "source": [ "# Earth Surface Temperature Analysis\n", "----------\n", "In this analysis I will be looking at the dataset _[Climate Change: Earth Surface Temperature Data](https://www.kaggle.com/berkeleyearth/climate-change-earth-surface-temperature-data)_ by Berkley Earth. This dataset consists of temperature readings from around the world that go back to at least the 1760's in some areas and up until 2013.\n", "\n", "*Note*: This analysis does not include the 95% confidence interval for temperatures.\n", "\n", "This notebook is best viewed with [Jupyter nbviewer](https://nbviewer.jupyter.org/github/kylepollina/Surface_Temperature_Analysis/blob/master/Earth%20Surface%20Temperature%20Analysis.ipynb). The *Contents* links will not work on Github.\n", "\n", "##### Contents\n", "1. [Preface](#Preface)\n", "2. [Global Land Temperatures By Country](#Global-Land-Temperatures-By-Country)\n", "3. [Global Land Temperatures By Major City](#Global-Land-Temperatures-By-Major-City)\n", "4. [Global Land Temperatures By State](#Global-Land-Temperatures-By-State)\n", "\n", " \n", "\n", "##### Links\n", "- Dataset: https://www.kaggle.com/berkeleyearth/climate-change-earth-surface-temperature-data\n", "- Notebook: [Jupyter nbviewer](https://nbviewer.jupyter.org/github/kylepollina/Surface_Temperature_Analysis/blob/master/Earth%20Surface%20Temperature%20Analysis.ipynb)\n", "- Source: https://github.com/circulEarth/SurfaceTemperatures\n", "- Author: https://github.com/kylepollina" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Preface\n", "----------\n", "\n", "1. [The data](#The-data)\n", "2. [Helper functions](#Helper-functions)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "### Packages\n", "- [pandas](https://pandas.pydata.org/): Used for reading data into [DataFrame](https://pandas.pydata.org/pandas-docs/stable/reference/api/pandas.DataFrame.html) objects\n", "- [altair](https://altair-viz.github.io/): Used for plotting and interactive visualization\n", "- [os](https://docs.python.org/3/library/os.html): Used for operating system behavior, specifically [walking](https://docs.python.org/3/library/os.html?highlight=os%20walk#os.walk) through the filesystem\n", "- [datetime.date](https://docs.python.org/2/library/datetime.html#date-objects): Used for reading/parsing dates from strings using [datetime.date.fromisoformat()](https://docs.python.org/3/library/datetime.html#datetime.date.fromisoformat)" ] }, { "cell_type": "code", "execution_count": 1, "metadata": {}, "outputs": [], "source": [ "import pandas\n", "import altair as alt\n", "import os\n", "from datetime import date" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "### The data\n", "This dataset consists of five sources. I have downloaded them into a directory named `/data/BerkleyEarth`. The `datafiles` list below consists of the names of each of the five .csv files. " ] }, { "cell_type": "code", "execution_count": 2, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "['data_sta/GlobalLandTemperaturesByCountry.csv', 'data_sta/GlobalLandTemperaturesByMajorCity.csv', 'data_sta/GlobalLandTemperaturesByState.csv', 'data_sta/GlobalTemperatures.csv', 'data_sta/GlobalLandTemperaturesByCity.csv']\n" ] } ], "source": [ "datafiles = []\n", "\n", "for directory, _, files in os.walk('data_sta'):\n", " for file in files:\n", " filename = os.path.join(directory, file)\n", " datafiles.append(filename)\n", "\n", "print(datafiles)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "`print_datafiles()` - Orderly print each datafile and index within the `datafiles` list" ] }, { "cell_type": "code", "execution_count": 3, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "0. data_sta/GlobalLandTemperaturesByCountry.csv\n", "1. data_sta/GlobalLandTemperaturesByMajorCity.csv\n", "2. data_sta/GlobalLandTemperaturesByState.csv\n", "3. data_sta/GlobalTemperatures.csv\n", "4. data_sta/GlobalLandTemperaturesByCity.csv\n" ] } ], "source": [ "def print_datafiles():\n", " for index, filename in enumerate(datafiles):\n", " print(str(index) + \". \" + filename)\n", " \n", "print_datafiles()" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "#### Temperatures by Country" ] }, { "cell_type": "code", "execution_count": 4, "metadata": {}, "outputs": [ { "data": { "text/html": [ "
\n", "\n", "\n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", "
dtAverageTemperatureAverageTemperatureUncertaintyCountry
01743-11-014.3842.294Åland
51744-04-011.5304.680Åland
61744-05-016.7021.789Åland
71744-06-0111.6091.577Åland
81744-07-0115.3421.410Åland
...............
5774562013-04-0121.1420.495Zimbabwe
5774572013-05-0119.0591.022Zimbabwe
5774582013-06-0117.6130.473Zimbabwe
5774592013-07-0117.0000.453Zimbabwe
5774602013-08-0119.7590.717Zimbabwe
\n", "

544811 rows × 4 columns

\n", "
" ], "text/plain": [ " dt AverageTemperature AverageTemperatureUncertainty \\\n", "0 1743-11-01 4.384 2.294 \n", "5 1744-04-01 1.530 4.680 \n", "6 1744-05-01 6.702 1.789 \n", "7 1744-06-01 11.609 1.577 \n", "8 1744-07-01 15.342 1.410 \n", "... ... ... ... \n", "577456 2013-04-01 21.142 0.495 \n", "577457 2013-05-01 19.059 1.022 \n", "577458 2013-06-01 17.613 0.473 \n", "577459 2013-07-01 17.000 0.453 \n", "577460 2013-08-01 19.759 0.717 \n", "\n", " Country \n", "0 Åland \n", "5 Åland \n", "6 Åland \n", "7 Åland \n", "8 Åland \n", "... ... \n", "577456 Zimbabwe \n", "577457 Zimbabwe \n", "577458 Zimbabwe \n", "577459 Zimbabwe \n", "577460 Zimbabwe \n", "\n", "[544811 rows x 4 columns]" ] }, "execution_count": 4, "metadata": {}, "output_type": "execute_result" } ], "source": [ "# Load country data into DataFrame named `country_temps`\n", "country_temps = pandas.read_csv('data_sta/GlobalLandTemperaturesByCountry.csv')\n", "\n", "# Drop any rows with a NaN/Empty values for any of the attributes\n", "country_temps = country_temps.dropna()\n", "\n", "# Save each unique country name into a set\n", "all_countries = set(country_temps['Country'])\n", "\n", "# Display DataFrame\n", "country_temps" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "#### Temperatures by State" ] }, { "cell_type": "code", "execution_count": 5, "metadata": {}, "outputs": [ { "data": { "text/html": [ "
\n", "\n", "\n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", "
dtAverageTemperatureAverageTemperatureUncertaintyStateCountry
01855-05-0125.5441.171AcreBrazil
11855-06-0124.2281.103AcreBrazil
21855-07-0124.3711.044AcreBrazil
31855-08-0125.4271.073AcreBrazil
41855-09-0125.6751.014AcreBrazil
..................
6456692013-04-0115.7100.461ZhejiangChina
6456702013-05-0121.6340.578ZhejiangChina
6456712013-06-0124.6790.596ZhejiangChina
6456722013-07-0129.2721.340ZhejiangChina
6456732013-08-0129.2020.869ZhejiangChina
\n", "

620027 rows × 5 columns

\n", "
" ], "text/plain": [ " dt AverageTemperature AverageTemperatureUncertainty \\\n", "0 1855-05-01 25.544 1.171 \n", "1 1855-06-01 24.228 1.103 \n", "2 1855-07-01 24.371 1.044 \n", "3 1855-08-01 25.427 1.073 \n", "4 1855-09-01 25.675 1.014 \n", "... ... ... ... \n", "645669 2013-04-01 15.710 0.461 \n", "645670 2013-05-01 21.634 0.578 \n", "645671 2013-06-01 24.679 0.596 \n", "645672 2013-07-01 29.272 1.340 \n", "645673 2013-08-01 29.202 0.869 \n", "\n", " State Country \n", "0 Acre Brazil \n", "1 Acre Brazil \n", "2 Acre Brazil \n", "3 Acre Brazil \n", "4 Acre Brazil \n", "... ... ... \n", "645669 Zhejiang China \n", "645670 Zhejiang China \n", "645671 Zhejiang China \n", "645672 Zhejiang China \n", "645673 Zhejiang China \n", "\n", "[620027 rows x 5 columns]" ] }, "execution_count": 5, "metadata": {}, "output_type": "execute_result" } ], "source": [ "# Load state data into DataFrame named `state_temps`\n", "state_temps = pandas.read_csv('data_sta/GlobalLandTemperaturesByState.csv')\n", "\n", "# Drop any rows with a NaN/Empty value for any of the attributes\n", "state_temps = state_temps.dropna()\n", "\n", "# Save each unique state name into a set\n", "all_states = set(state_temps['State'])\n", "\n", "# Display DataFrame\n", "state_temps" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "#### Temperature by Major City" ] }, { "cell_type": "code", "execution_count": 6, "metadata": {}, "outputs": [ { "data": { "text/html": [ "
\n", "\n", "\n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", "
dtAverageTemperatureAverageTemperatureUncertaintyCityCountryLatitudeLongitude
01849-01-0126.7041.435AbidjanCôte D'Ivoire5.63N3.23W
11849-02-0127.4341.362AbidjanCôte D'Ivoire5.63N3.23W
21849-03-0128.1011.612AbidjanCôte D'Ivoire5.63N3.23W
31849-04-0126.1401.387AbidjanCôte D'Ivoire5.63N3.23W
41849-05-0125.4271.200AbidjanCôte D'Ivoire5.63N3.23W
........................
2391712013-04-0112.5631.823XianChina34.56N108.97E
2391722013-05-0118.9790.807XianChina34.56N108.97E
2391732013-06-0123.5220.647XianChina34.56N108.97E
2391742013-07-0125.2511.042XianChina34.56N108.97E
2391752013-08-0124.5280.840XianChina34.56N108.97E
\n", "

228175 rows × 7 columns

\n", "
" ], "text/plain": [ " dt AverageTemperature AverageTemperatureUncertainty \\\n", "0 1849-01-01 26.704 1.435 \n", "1 1849-02-01 27.434 1.362 \n", "2 1849-03-01 28.101 1.612 \n", "3 1849-04-01 26.140 1.387 \n", "4 1849-05-01 25.427 1.200 \n", "... ... ... ... \n", "239171 2013-04-01 12.563 1.823 \n", "239172 2013-05-01 18.979 0.807 \n", "239173 2013-06-01 23.522 0.647 \n", "239174 2013-07-01 25.251 1.042 \n", "239175 2013-08-01 24.528 0.840 \n", "\n", " City Country Latitude Longitude \n", "0 Abidjan Côte D'Ivoire 5.63N 3.23W \n", "1 Abidjan Côte D'Ivoire 5.63N 3.23W \n", "2 Abidjan Côte D'Ivoire 5.63N 3.23W \n", "3 Abidjan Côte D'Ivoire 5.63N 3.23W \n", "4 Abidjan Côte D'Ivoire 5.63N 3.23W \n", "... ... ... ... ... \n", "239171 Xian China 34.56N 108.97E \n", "239172 Xian China 34.56N 108.97E \n", "239173 Xian China 34.56N 108.97E \n", "239174 Xian China 34.56N 108.97E \n", "239175 Xian China 34.56N 108.97E \n", "\n", "[228175 rows x 7 columns]" ] }, "execution_count": 6, "metadata": {}, "output_type": "execute_result" } ], "source": [ "# Load state data into DataFrame named `major_city_temps`\n", "major_city_temps = pandas.read_csv('data_sta/GlobalLandTemperaturesByMajorCity.csv')\n", "\n", "# Drop any rows with a NaN/Empty value for any of the attributes\n", "major_city_temps = major_city_temps.dropna()\n", "\n", "# Save each unique major city name into a set\n", "all_major_cities = set(major_city_temps['City'])\n", "\n", "# Display DataFrame\n", "major_city_temps" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "#### Temperature by City\n", "The 'Temperature By City' dataset is much larger than the others and takes significantly more time to load. I have commented out the loading of the dataset to save run time, but left this in for possible future analysis of each city." ] }, { "cell_type": "code", "execution_count": 7, "metadata": {}, "outputs": [], "source": [ "# Load state data into DataFrame named `major_city_temps`\n", "# city_temps = pandas.read_csv('data/BerkleyEarth/GlobalLandTemperaturesByCity.csv')\n", "\n", "# Drop any rows with a NaN/Empty value for any of the attributes\n", "# city_temps = city_temps.dropna() \n", "\n", "# Save each unique major city name into a set\n", "# all_cities = set(city_temps['City'])\n", "\n", "# Display DataFrame\n", "# city_temps" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "### Helper functions" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "`yearly_temps(location)` - Returns a [DataFrame](https://pandas.pydata.org/pandas-docs/stable/reference/api/pandas.DataFrame.html) of average temperatures recorded over each year for given location.\n", "\n", "Parameters:\n", "- `location` - String of location, name of Country, State, or Major City\n", "- `dataset` - Optional argument to force lookup in specific dataset. For example, `New York` appears in `state_temps` and `major_city_temps`. `dataset` can equal one of the following three values (defaults to `None` if no dataset specified):\n", " - `'Country'`\n", " - `'State'`\n", " - `'Major City'`\n", "\n", "*examples* \n", "\n", "`new_york_temps = yearly_temps('New York', dataset = 'State')`\n", "\n", "`new_york_city_temps = yearly_temps('New York', dataset = 'Major City')`" ] }, { "cell_type": "code", "execution_count": 8, "metadata": {}, "outputs": [], "source": [ "def get_yearly_temps(location, dataset = None):\n", " \n", " # Search location in country dataset\n", " if location in all_countries and (dataset is None or (dataset == 'Country')):\n", " # Filter country_temps by given country\n", " filtered_temps = country_temps[country_temps['Country'] == location]\n", " \n", " # Search location in state dataset\n", " elif location in all_states and (dataset is None or (dataset == 'State')):\n", " # Filter state_temps by given state\n", " filtered_temps = state_temps[state_temps['State'] == location]\n", " \n", " # Search location in major city dataset\n", " elif location in all_major_cities and (dataset is None or (dataset == 'Major City')):\n", " # Filter major_city_temps by given city\n", " filtered_temps = major_city_temps[major_city_temps['City'] == location]\n", " \n", " # Location not found\n", " else:\n", " raise ValueError(\"Location not found in any loaded dataset\")\n", " \n", " # Sort recorded temperatures by date\n", " filtered_temps = filtered_temps.sort_values(by = ['dt'])\n", " \n", " # Result data to be returned\n", " yearly_temps = {'Year': [], 'AverageTemperature': []}\n", " \n", " # Get year from ISO date\n", " first_recorded_year = date.fromisoformat(filtered_temps.iloc[0]['dt']).year\n", " current_year = first_recorded_year\n", " \n", " # Sum and total used for averaging\n", " sum_temps = 0.0\n", " total_dates_in_year = 0\n", " \n", " for index, row in filtered_temps.iterrows():\n", " # Convert the `dt` value into a Python Date object\n", " current_date = date.fromisoformat(row['dt'])\n", " \n", " # If we have switched over into a new year\n", " if current_date.year != current_year: \n", " # Average temperatures over previous year\n", " yearly_avg_temp = sum_temps / total_dates_in_year\n", " \n", " # Add to result data\n", " yearly_temps['Year'].append(current_year)\n", " yearly_temps['AverageTemperature'].append(yearly_avg_temp)\n", " \n", " # Update current_year\n", " current_year = current_date.year\n", " \n", " # Reset sum/total\n", " sum_temps = 0.0\n", " total_dates_in_year = 0\n", " \n", " # Increase sum/total\n", " sum_temps += row['AverageTemperature']\n", " total_dates_in_year += 1\n", " \n", " # Convert resulting data into DataFrame and return\n", " return pandas.DataFrame(data = yearly_temps)\n", " " ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Global Land Temperatures By Country\n", "-------\n", "\n", "1. [North America](#North-America)\n", "2. [South America](#South-America)\n", "3. [Europe](#Europe)\n", "4. [Africa](#Africa)\n", "5. [Asia](#Asia)\n", "6. [Oceania](#Oceania)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "### North America" ] }, { "cell_type": "code", "execution_count": 9, "metadata": {}, "outputs": [ { "data": { "text/html": [ "\n", "
\n", "" ], "text/plain": [ "alt.Chart(...)" ] }, "execution_count": 9, "metadata": {}, "output_type": "execute_result" } ], "source": [ "location = 'United States'\n", "temps = get_yearly_temps(location)\n", "\n", "# Line plot using Altair\n", "alt.Chart(temps).mark_line().encode(\n", " x = 'Year:O',\n", " y = alt.Y('AverageTemperature', scale=alt.Scale(zero=False))\n", ").properties(\n", " title = 'Yearly Average Temperatures (C) of ' + location,\n", " width = 800\n", ")" ] }, { "cell_type": "code", "execution_count": 10, "metadata": {}, "outputs": [ { "data": { "text/html": [ "\n", "
\n", "" ], "text/plain": [ "alt.Chart(...)" ] }, "execution_count": 10, "metadata": {}, "output_type": "execute_result" } ], "source": [ "location = 'Canada'\n", "temps = get_yearly_temps(location)\n", "\n", "# Line plot using Altair\n", "alt.Chart(temps).mark_line().encode(\n", " x = 'Year:O',\n", " y = alt.Y('AverageTemperature', scale=alt.Scale(zero=False))\n", ").properties(\n", " title = 'Yearly Average Temperatures (C) of ' + location,\n", " width = 800\n", ")" ] }, { "cell_type": "code", "execution_count": 11, "metadata": {}, "outputs": [ { "data": { "text/html": [ "\n", "
\n", "" ], "text/plain": [ "alt.Chart(...)" ] }, "execution_count": 11, "metadata": {}, "output_type": "execute_result" } ], "source": [ "location = 'Mexico'\n", "temps = get_yearly_temps(location)\n", "\n", "# Line plot using Altair\n", "alt.Chart(temps).mark_line().encode(\n", " x = 'Year:O',\n", " y = alt.Y('AverageTemperature', scale=alt.Scale(zero=False))\n", ").properties(\n", " title = 'Yearly Average Temperatures (C) of ' + location,\n", " width = 800\n", ")" ] }, { "cell_type": "code", "execution_count": 12, "metadata": {}, "outputs": [ { "data": { "text/html": [ "\n", "
\n", "" ], "text/plain": [ "alt.Chart(...)" ] }, "execution_count": 12, "metadata": {}, "output_type": "execute_result" } ], "source": [ "location = 'North America'\n", "temps = get_yearly_temps(location)\n", "\n", "# Line plot using Altair\n", "alt.Chart(temps).mark_line().encode(\n", " x = 'Year:O',\n", " y = alt.Y('AverageTemperature', scale=alt.Scale(zero=False))\n", ").properties(\n", " title = 'Yearly Average Temperatures (C) of ' + location,\n", " width = 800\n", ")" ] }, { "cell_type": "code", "execution_count": 13, "metadata": {}, "outputs": [ { "data": { "text/html": [ "\n", "
\n", "" ], "text/plain": [ "alt.Chart(...)" ] }, "execution_count": 13, "metadata": {}, "output_type": "execute_result" } ], "source": [ "location = 'North America'\n", "temps = get_yearly_temps(location)\n", "\n", "# Line plot using Altair\n", "alt.Chart(temps).mark_line().encode(\n", " x = 'Year:O',\n", " y = alt.Y('AverageTemperature', scale=alt.Scale(zero=False))\n", ").properties(\n", " title = 'Yearly Average Temperatures (C) of ' + location,\n", " width = 800\n", ")" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "### South America" ] }, { "cell_type": "code", "execution_count": 14, "metadata": {}, "outputs": [ { "data": { "text/html": [ "\n", "
\n", "" ], "text/plain": [ "alt.Chart(...)" ] }, "execution_count": 14, "metadata": {}, "output_type": "execute_result" } ], "source": [ "location = 'Brazil'\n", "temps = get_yearly_temps(location)\n", "\n", "# Line plot using Altair\n", "alt.Chart(temps).mark_line().encode(\n", " x = 'Year:O',\n", " y = alt.Y('AverageTemperature', scale=alt.Scale(zero=False))\n", ").properties(\n", " title = 'Yearly Average Temperatures (C) of ' + location,\n", " width = 800\n", ")" ] }, { "cell_type": "code", "execution_count": 15, "metadata": {}, "outputs": [ { "data": { "text/html": [ "\n", "
\n", "" ], "text/plain": [ "alt.Chart(...)" ] }, "execution_count": 15, "metadata": {}, "output_type": "execute_result" } ], "source": [ "location = 'Chile'\n", "temps = get_yearly_temps(location)\n", "\n", "# Line plot using Altair\n", "alt.Chart(temps).mark_line().encode(\n", " x = 'Year:O',\n", " y = alt.Y('AverageTemperature', scale=alt.Scale(zero=False))\n", ").properties(\n", " title = 'Yearly Average Temperatures (C) of ' + location,\n", " width = 800\n", ")" ] }, { "cell_type": "code", "execution_count": 16, "metadata": {}, "outputs": [ { "data": { "text/html": [ "\n", "
\n", "" ], "text/plain": [ "alt.Chart(...)" ] }, "execution_count": 16, "metadata": {}, "output_type": "execute_result" } ], "source": [ "location = 'Argentina'\n", "temps = get_yearly_temps(location)\n", "\n", "# Line plot using Altair\n", "alt.Chart(temps).mark_line().encode(\n", " x = 'Year:O',\n", " y = alt.Y('AverageTemperature', scale=alt.Scale(zero=False))\n", ").properties(\n", " title = 'Yearly Average Temperatures (C) of ' + location,\n", " width = 800\n", ")" ] }, { "cell_type": "code", "execution_count": 17, "metadata": {}, "outputs": [ { "data": { "text/html": [ "\n", "
\n", "" ], "text/plain": [ "alt.Chart(...)" ] }, "execution_count": 17, "metadata": {}, "output_type": "execute_result" } ], "source": [ "location = 'Venezuela'\n", "temps = get_yearly_temps(location)\n", "\n", "# Line plot using Altair\n", "alt.Chart(temps).mark_line().encode(\n", " x = 'Year:O',\n", " y = alt.Y('AverageTemperature', scale=alt.Scale(zero=False))\n", ").properties(\n", " title = 'Yearly Average Temperatures (C) of ' + location,\n", " width = 800\n", ")" ] }, { "cell_type": "code", "execution_count": 18, "metadata": {}, "outputs": [ { "data": { "text/html": [ "\n", "
\n", "" ], "text/plain": [ "alt.Chart(...)" ] }, "execution_count": 18, "metadata": {}, "output_type": "execute_result" } ], "source": [ "location = 'South America'\n", "temps = get_yearly_temps(location)\n", "\n", "# Line plot using Altair\n", "alt.Chart(temps).mark_line().encode(\n", " x = 'Year:O',\n", " y = alt.Y('AverageTemperature', scale=alt.Scale(zero=False))\n", ").properties(\n", " title = 'Yearly Average Temperatures (C) of ' + location,\n", " width = 800\n", ")" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "### Europe" ] }, { "cell_type": "code", "execution_count": 19, "metadata": {}, "outputs": [ { "data": { "text/html": [ "\n", "
\n", "" ], "text/plain": [ "alt.Chart(...)" ] }, "execution_count": 19, "metadata": {}, "output_type": "execute_result" } ], "source": [ "location = 'United Kingdom'\n", "temps = get_yearly_temps(location)\n", "\n", "# Line plot using Altair\n", "alt.Chart(temps).mark_line().encode(\n", " x = 'Year:O',\n", " y = alt.Y('AverageTemperature', scale=alt.Scale(zero=False))\n", ").properties(\n", " title = 'Yearly Average Temperatures (C) of ' + location,\n", " width = 800\n", ")" ] }, { "cell_type": "code", "execution_count": 20, "metadata": {}, "outputs": [ { "data": { "text/html": [ "\n", "
\n", "" ], "text/plain": [ "alt.Chart(...)" ] }, "execution_count": 20, "metadata": {}, "output_type": "execute_result" } ], "source": [ "location = 'France'\n", "temps = get_yearly_temps(location)\n", "\n", "# Line plot using Altair\n", "alt.Chart(temps).mark_line().encode(\n", " x = 'Year:O',\n", " y = alt.Y('AverageTemperature', scale=alt.Scale(zero=False))\n", ").properties(\n", " title = 'Yearly Average Temperatures (C) of ' + location,\n", " width = 800\n", ")" ] }, { "cell_type": "code", "execution_count": 21, "metadata": {}, "outputs": [ { "data": { "text/html": [ "\n", "
\n", "" ], "text/plain": [ "alt.Chart(...)" ] }, "execution_count": 21, "metadata": {}, "output_type": "execute_result" } ], "source": [ "location = 'Germany'\n", "temps = get_yearly_temps(location)\n", "\n", "# Line plot using Altair\n", "alt.Chart(temps).mark_line().encode(\n", " x = 'Year:O',\n", " y = alt.Y('AverageTemperature', scale=alt.Scale(zero=False))\n", ").properties(\n", " title = 'Yearly Average Temperatures (C) of ' + location,\n", " width = 800\n", ")" ] }, { "cell_type": "code", "execution_count": 22, "metadata": {}, "outputs": [ { "data": { "text/html": [ "\n", "
\n", "" ], "text/plain": [ "alt.Chart(...)" ] }, "execution_count": 22, "metadata": {}, "output_type": "execute_result" } ], "source": [ "location = 'Spain'\n", "temps = get_yearly_temps(location)\n", "\n", "# Line plot using Altair\n", "alt.Chart(temps).mark_line().encode(\n", " x = 'Year:O',\n", " y = alt.Y('AverageTemperature', scale=alt.Scale(zero=False))\n", ").properties(\n", " title = 'Yearly Average Temperatures (C) of ' + location,\n", " width = 800\n", ")" ] }, { "cell_type": "code", "execution_count": 23, "metadata": {}, "outputs": [ { "data": { "text/html": [ "\n", "
\n", "" ], "text/plain": [ "alt.Chart(...)" ] }, "execution_count": 23, "metadata": {}, "output_type": "execute_result" } ], "source": [ "location = 'Sweden'\n", "temps = get_yearly_temps(location)\n", "\n", "# Line plot using Altair\n", "alt.Chart(temps).mark_line().encode(\n", " x = 'Year:O',\n", " y = alt.Y('AverageTemperature', scale=alt.Scale(zero=False))\n", ").properties(\n", " title = 'Yearly Average Temperatures (C) of ' + location,\n", " width = 800\n", ")" ] }, { "cell_type": "code", "execution_count": 24, "metadata": {}, "outputs": [ { "data": { "text/html": [ "\n", "
\n", "" ], "text/plain": [ "alt.Chart(...)" ] }, "execution_count": 24, "metadata": {}, "output_type": "execute_result" } ], "source": [ "location = 'Europe'\n", "temps = get_yearly_temps(location)\n", "\n", "# Line plot using Altair\n", "alt.Chart(temps).mark_line().encode(\n", " x = 'Year:O',\n", " y = alt.Y('AverageTemperature', scale=alt.Scale(zero=False))\n", ").properties(\n", " title = 'Yearly Average Temperatures (C) of ' + location,\n", " width = 800\n", ")" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "### Africa" ] }, { "cell_type": "code", "execution_count": 25, "metadata": {}, "outputs": [ { "data": { "text/html": [ "\n", "
\n", "" ], "text/plain": [ "alt.Chart(...)" ] }, "execution_count": 25, "metadata": {}, "output_type": "execute_result" } ], "source": [ "location = 'Egypt'\n", "temps = get_yearly_temps(location)\n", "\n", "# Line plot using Altair\n", "alt.Chart(temps).mark_line().encode(\n", " x = 'Year:O',\n", " y = alt.Y('AverageTemperature', scale=alt.Scale(zero=False))\n", ").properties(\n", " title = 'Yearly Average Temperatures (C) of ' + location,\n", " width = 800\n", ")" ] }, { "cell_type": "code", "execution_count": 26, "metadata": {}, "outputs": [ { "data": { "text/html": [ "\n", "
\n", "" ], "text/plain": [ "alt.Chart(...)" ] }, "execution_count": 26, "metadata": {}, "output_type": "execute_result" } ], "source": [ "location = 'South Africa'\n", "temps = get_yearly_temps(location)\n", "\n", "# Line plot using Altair\n", "alt.Chart(temps).mark_line().encode(\n", " x = 'Year:O',\n", " y = alt.Y('AverageTemperature', scale=alt.Scale(zero=False))\n", ").properties(\n", " title = 'Yearly Average Temperatures (C) of ' + location,\n", " width = 800\n", ")" ] }, { "cell_type": "code", "execution_count": 27, "metadata": {}, "outputs": [ { "data": { "text/html": [ "\n", "
\n", "" ], "text/plain": [ "alt.Chart(...)" ] }, "execution_count": 27, "metadata": {}, "output_type": "execute_result" } ], "source": [ "location = 'Kenya'\n", "temps = get_yearly_temps(location)\n", "\n", "# Line plot using Altair\n", "alt.Chart(temps).mark_line().encode(\n", " x = 'Year:O',\n", " y = alt.Y('AverageTemperature', scale=alt.Scale(zero=False))\n", ").properties(\n", " title = 'Yearly Average Temperatures (C) of ' + location,\n", " width = 800\n", ")" ] }, { "cell_type": "code", "execution_count": 28, "metadata": {}, "outputs": [ { "data": { "text/html": [ "\n", "
\n", "" ], "text/plain": [ "alt.Chart(...)" ] }, "execution_count": 28, "metadata": {}, "output_type": "execute_result" } ], "source": [ "location = 'Uganda'\n", "temps = get_yearly_temps(location)\n", "\n", "# Line plot using Altair\n", "alt.Chart(temps).mark_line().encode(\n", " x = 'Year:O',\n", " y = alt.Y('AverageTemperature', scale=alt.Scale(zero=False))\n", ").properties(\n", " title = 'Yearly Average Temperatures (C) of ' + location,\n", " width = 800\n", ")" ] }, { "cell_type": "code", "execution_count": 29, "metadata": {}, "outputs": [ { "data": { "text/html": [ "\n", "
\n", "" ], "text/plain": [ "alt.Chart(...)" ] }, "execution_count": 29, "metadata": {}, "output_type": "execute_result" } ], "source": [ "location = 'Africa'\n", "temps = get_yearly_temps(location)\n", "\n", "# Line plot using Altair\n", "alt.Chart(temps).mark_line().encode(\n", " x = 'Year:O',\n", " y = alt.Y('AverageTemperature', scale=alt.Scale(zero=False))\n", ").properties(\n", " title = 'Yearly Average Temperatures (C) of ' + location,\n", " width = 800\n", ")" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "### Asia" ] }, { "cell_type": "code", "execution_count": 30, "metadata": {}, "outputs": [ { "data": { "text/html": [ "\n", "
\n", "" ], "text/plain": [ "alt.Chart(...)" ] }, "execution_count": 30, "metadata": {}, "output_type": "execute_result" } ], "source": [ "location = 'China'\n", "temps = get_yearly_temps(location)\n", "\n", "# Line plot using Altair\n", "alt.Chart(temps).mark_line().encode(\n", " x = 'Year:O',\n", " y = alt.Y('AverageTemperature', scale=alt.Scale(zero=False))\n", ").properties(\n", " title = 'Yearly Average Temperatures (C) of ' + location,\n", " width = 800\n", ")" ] }, { "cell_type": "code", "execution_count": 31, "metadata": {}, "outputs": [ { "data": { "text/html": [ "\n", "
\n", "" ], "text/plain": [ "alt.Chart(...)" ] }, "execution_count": 31, "metadata": {}, "output_type": "execute_result" } ], "source": [ "location = 'India'\n", "temps = get_yearly_temps(location)\n", "\n", "# Line plot using Altair\n", "alt.Chart(temps).mark_line().encode(\n", " x = 'Year:O',\n", " y = alt.Y('AverageTemperature', scale=alt.Scale(zero=False))\n", ").properties(\n", " title = 'Yearly Average Temperatures (C) of ' + location,\n", " width = 800\n", ")" ] }, { "cell_type": "code", "execution_count": 32, "metadata": {}, "outputs": [ { "data": { "text/html": [ "\n", "
\n", "" ], "text/plain": [ "alt.Chart(...)" ] }, "execution_count": 32, "metadata": {}, "output_type": "execute_result" } ], "source": [ "location = 'Russia'\n", "temps = get_yearly_temps(location)\n", "\n", "# Line plot using Altair\n", "alt.Chart(temps).mark_line().encode(\n", " x = 'Year:O',\n", " y = alt.Y('AverageTemperature', scale=alt.Scale(zero=False))\n", ").properties(\n", " title = 'Yearly Average Temperatures (C) of ' + location,\n", " width = 800\n", ")" ] }, { "cell_type": "code", "execution_count": 33, "metadata": {}, "outputs": [ { "data": { "text/html": [ "\n", "
\n", "" ], "text/plain": [ "alt.Chart(...)" ] }, "execution_count": 33, "metadata": {}, "output_type": "execute_result" } ], "source": [ "location = 'Japan'\n", "temps = get_yearly_temps(location)\n", "\n", "# Line plot using Altair\n", "alt.Chart(temps).mark_line().encode(\n", " x = 'Year:O',\n", " y = alt.Y('AverageTemperature', scale=alt.Scale(zero=False))\n", ").properties(\n", " title = 'Yearly Average Temperatures (C) of ' + location,\n", " width = 800\n", ")" ] }, { "cell_type": "code", "execution_count": 34, "metadata": {}, "outputs": [ { "data": { "text/html": [ "\n", "
\n", "" ], "text/plain": [ "alt.Chart(...)" ] }, "execution_count": 34, "metadata": {}, "output_type": "execute_result" } ], "source": [ "location = 'Asia'\n", "temps = get_yearly_temps(location)\n", "\n", "# Line plot using Altair\n", "alt.Chart(temps).mark_line().encode(\n", " x = 'Year:O',\n", " y = alt.Y('AverageTemperature', scale=alt.Scale(zero=False))\n", ").properties(\n", " title = 'Yearly Average Temperatures (C) of ' + location,\n", " width = 800\n", ")" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "### Oceania" ] }, { "cell_type": "code", "execution_count": 35, "metadata": {}, "outputs": [ { "data": { "text/html": [ "\n", "
\n", "" ], "text/plain": [ "alt.Chart(...)" ] }, "execution_count": 35, "metadata": {}, "output_type": "execute_result" } ], "source": [ "location = 'Australia'\n", "temps = get_yearly_temps(location)\n", "\n", "# Line plot using Altair\n", "alt.Chart(temps).mark_line().encode(\n", " x = 'Year:O',\n", " y = alt.Y('AverageTemperature', scale=alt.Scale(zero=False))\n", ").properties(\n", " title = 'Yearly Average Temperatures (C) of ' + location,\n", " width = 800\n", ")" ] }, { "cell_type": "code", "execution_count": 36, "metadata": {}, "outputs": [ { "data": { "text/html": [ "\n", "
\n", "" ], "text/plain": [ "alt.Chart(...)" ] }, "execution_count": 36, "metadata": {}, "output_type": "execute_result" } ], "source": [ "location = 'New Zealand'\n", "temps = get_yearly_temps(location)\n", "\n", "# Line plot using Altair\n", "alt.Chart(temps).mark_line().encode(\n", " x = 'Year:O',\n", " y = alt.Y('AverageTemperature', scale=alt.Scale(zero=False))\n", ").properties(\n", " title = 'Yearly Average Temperatures (C) of ' + location,\n", " width = 800\n", ")" ] }, { "cell_type": "code", "execution_count": 37, "metadata": {}, "outputs": [ { "data": { "text/html": [ "\n", "
\n", "" ], "text/plain": [ "alt.Chart(...)" ] }, "execution_count": 37, "metadata": {}, "output_type": "execute_result" } ], "source": [ "location = 'Papua New Guinea'\n", "temps = get_yearly_temps(location)\n", "\n", "# Line plot using Altair\n", "alt.Chart(temps).mark_line().encode(\n", " x = 'Year:O',\n", " y = alt.Y('AverageTemperature', scale=alt.Scale(zero=False))\n", ").properties(\n", " title = 'Yearly Average Temperatures (C) of ' + location,\n", " width = 800\n", ")" ] }, { "cell_type": "code", "execution_count": 38, "metadata": {}, "outputs": [ { "data": { "text/html": [ "\n", "
\n", "" ], "text/plain": [ "alt.Chart(...)" ] }, "execution_count": 38, "metadata": {}, "output_type": "execute_result" } ], "source": [ "location = 'Oceania'\n", "temps = get_yearly_temps(location)\n", "\n", "# Line plot using Altair\n", "alt.Chart(temps).mark_line().encode(\n", " x = 'Year:O',\n", " y = alt.Y('AverageTemperature', scale=alt.Scale(zero=False))\n", ").properties(\n", " title = 'Yearly Average Temperatures (C) of ' + location,\n", " width = 800\n", ")" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Global Land Temperatures By Major City\n", "-------\n", "1. [New York City](#New-York-City)\n", "2. [Los Angeles](#Los-Angeles)\n", "3. [Chicago](#Chicago)\n", "4. [London](#London)\n", "5. [Paris](#Paris)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "### New York City" ] }, { "cell_type": "code", "execution_count": 39, "metadata": {}, "outputs": [ { "data": { "text/html": [ "\n", "
\n", "" ], "text/plain": [ "alt.Chart(...)" ] }, "execution_count": 39, "metadata": {}, "output_type": "execute_result" } ], "source": [ "location = 'New York'\n", "temps = get_yearly_temps(location, dataset = 'Major City')\n", "\n", "# Line plot using Altair\n", "alt.Chart(temps).mark_line().encode(\n", " x = 'Year:O',\n", " y = alt.Y('AverageTemperature', scale=alt.Scale(zero=False))\n", ").properties(\n", " title = 'Yearly Average Temperatures (C) of ' + location,\n", " width = 800\n", ")" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "### Los Angeles" ] }, { "cell_type": "code", "execution_count": 40, "metadata": {}, "outputs": [ { "data": { "text/html": [ "\n", "
\n", "" ], "text/plain": [ "alt.Chart(...)" ] }, "execution_count": 40, "metadata": {}, "output_type": "execute_result" } ], "source": [ "location = 'Los Angeles'\n", "temps = get_yearly_temps(location)\n", "\n", "# Line plot using Altair\n", "alt.Chart(temps).mark_line().encode(\n", " x = 'Year:O',\n", " y = alt.Y('AverageTemperature', scale=alt.Scale(zero=False))\n", ").properties(\n", " title = 'Yearly Average Temperatures (C) of ' + location,\n", " width = 800\n", ")" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "### Chicago" ] }, { "cell_type": "code", "execution_count": 41, "metadata": {}, "outputs": [ { "data": { "text/html": [ "\n", "
\n", "" ], "text/plain": [ "alt.Chart(...)" ] }, "execution_count": 41, "metadata": {}, "output_type": "execute_result" } ], "source": [ "location = 'Chicago'\n", "temps = get_yearly_temps(location)\n", "\n", "# Line plot using Altair\n", "alt.Chart(temps).mark_line().encode(\n", " x = 'Year:O',\n", " y = alt.Y('AverageTemperature', scale=alt.Scale(zero=False))\n", ").properties(\n", " title = 'Yearly Average Temperatures (C) of ' + location,\n", " width = 800\n", ")" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "### London" ] }, { "cell_type": "code", "execution_count": 42, "metadata": {}, "outputs": [ { "data": { "text/html": [ "\n", "
\n", "" ], "text/plain": [ "alt.Chart(...)" ] }, "execution_count": 42, "metadata": {}, "output_type": "execute_result" } ], "source": [ "location = 'London'\n", "temps = get_yearly_temps(location)\n", "\n", "# Line plot using Altair\n", "alt.Chart(temps).mark_line().encode(\n", " x = 'Year:O',\n", " y = alt.Y('AverageTemperature', scale=alt.Scale(zero=False))\n", ").properties(\n", " title = 'Yearly Average Temperatures (C) of ' + location,\n", " width = 800\n", ")" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "### Paris" ] }, { "cell_type": "code", "execution_count": 43, "metadata": {}, "outputs": [ { "data": { "text/html": [ "\n", "
\n", "" ], "text/plain": [ "alt.Chart(...)" ] }, "execution_count": 43, "metadata": {}, "output_type": "execute_result" } ], "source": [ "location = 'Paris'\n", "temps = get_yearly_temps(location)\n", "\n", "# Line plot using Altair\n", "alt.Chart(temps).mark_line().encode(\n", " x = 'Year:O',\n", " y = alt.Y('AverageTemperature', scale=alt.Scale(zero=False))\n", ").properties(\n", " title = 'Yearly Average Temperatures (C) of ' + location,\n", " width = 800\n", ")" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Global Land Temperatures By State\n", "-------\n", "1. [Illinois](#Illinois)\n", "2. [California](#California)\n", "3. [Florida](#Florida)\n", "4. [Texas](#Texas)\n", "5. [New York](#New-York)\n", " \n", "Here I will be focusing on U.S. states, but states from other countries are included in the dataset." ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "### Illinois" ] }, { "cell_type": "code", "execution_count": 44, "metadata": {}, "outputs": [ { "data": { "text/html": [ "\n", "
\n", "" ], "text/plain": [ "alt.Chart(...)" ] }, "execution_count": 44, "metadata": {}, "output_type": "execute_result" } ], "source": [ "location = 'Illinois'\n", "temps = get_yearly_temps(location)\n", "\n", "# Line plot using Altair\n", "alt.Chart(temps).mark_line().encode(\n", " x = 'Year:O',\n", " y = alt.Y('AverageTemperature', scale=alt.Scale(zero=False))\n", ").properties(\n", " title = 'Yearly Average Temperatures (C) of ' + location,\n", " width = 800\n", ")" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "### California" ] }, { "cell_type": "code", "execution_count": 45, "metadata": {}, "outputs": [ { "data": { "text/html": [ "\n", "
\n", "" ], "text/plain": [ "alt.Chart(...)" ] }, "execution_count": 45, "metadata": {}, "output_type": "execute_result" } ], "source": [ "location = 'California'\n", "temps = get_yearly_temps(location)\n", "\n", "# Line plot using Altair\n", "alt.Chart(temps).mark_line().encode(\n", " x = 'Year:O',\n", " y = alt.Y('AverageTemperature', scale=alt.Scale(zero=False))\n", ").properties(\n", " title = 'Yearly Average Temperatures (C) of ' + location,\n", " width = 800\n", ")" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "### Florida" ] }, { "cell_type": "code", "execution_count": 46, "metadata": {}, "outputs": [ { "data": { "text/html": [ "\n", "
\n", "" ], "text/plain": [ "alt.Chart(...)" ] }, "execution_count": 46, "metadata": {}, "output_type": "execute_result" } ], "source": [ "location = 'Florida'\n", "temps = get_yearly_temps(location)\n", "\n", "# Line plot using Altair\n", "alt.Chart(temps).mark_line().encode(\n", " x = 'Year:O',\n", " y = alt.Y('AverageTemperature', scale=alt.Scale(zero=False))\n", ").properties(\n", " title = 'Yearly Average Temperatures (C) of ' + location,\n", " width = 800\n", ")" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "### Texas" ] }, { "cell_type": "code", "execution_count": 47, "metadata": {}, "outputs": [ { "data": { "text/html": [ "\n", "
\n", "" ], "text/plain": [ "alt.Chart(...)" ] }, "execution_count": 47, "metadata": {}, "output_type": "execute_result" } ], "source": [ "location = 'Texas'\n", "temps = get_yearly_temps(location)\n", "\n", "# Line plot using Altair\n", "alt.Chart(temps).mark_line().encode(\n", " x = 'Year:O',\n", " y = alt.Y('AverageTemperature', scale=alt.Scale(zero=False))\n", ").properties(\n", " title = 'Yearly Average Temperatures (C) of ' + location,\n", " width = 800\n", ")" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "### New York" ] }, { "cell_type": "code", "execution_count": 48, "metadata": {}, "outputs": [ { "data": { "text/html": [ "\n", "
\n", "" ], "text/plain": [ "alt.Chart(...)" ] }, "execution_count": 48, "metadata": {}, "output_type": "execute_result" } ], "source": [ "location = 'New York'\n", "temps = get_yearly_temps(location, dataset = 'State')\n", "\n", "# Line plot using Altair\n", "alt.Chart(temps).mark_line().encode(\n", " x = 'Year:O',\n", " y = alt.Y('AverageTemperature', scale=alt.Scale(zero=False))\n", ").properties(\n", " title = 'Yearly Average Temperatures (C) of ' + location,\n", " width = 800\n", ")" ] } ], "metadata": { "kernelspec": { "display_name": "earthscience", "language": "python", "name": "earthscience" }, "language_info": { "codemirror_mode": { "name": "ipython", "version": 3 }, "file_extension": ".py", "mimetype": "text/x-python", "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", "version": "3.8.1" } }, "nbformat": 4, "nbformat_minor": 4 }