{ "cells": [ { "cell_type": "markdown", "metadata": {}, "source": [ "# Periodic Trends\n", "Charting the Patterns of Elements\n", "\n", "#### Step 1 - Creating a Checkpoint\n", ">Create a checkpoint by clicking File ==> Save and Checkpoint. If you make a major mistake, you can click File ==> Revert to Checkpoint to reset the Jupyter Notebook online on Binder.org." ] }, { "cell_type": "code", "execution_count": null, "metadata": { "collapsed": false }, "outputs": [], "source": [ "# Import modules that contain functions we need\n", "import pandas as pd\n", "import numpy as np\n", "%matplotlib inline\n", "import matplotlib.pyplot as plt" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Pre-Questions\n", ">Using the coding block below and what you've learned in this unit, answer questions 1 & 2. In order to display different versions of the periodic table, add or remove the # in front of Image(url...). Only one image can be displayed at once. After adding/removing the #s, execute the cells using Shift + Enter to display another image.\n" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "collapsed": false }, "outputs": [], "source": [ "# This code imports the image of the periodic table from the URL below\n", "#uncomment the image(url=... for the periodic table you would like to see. Be sure only one is uncommented at a time.\n", "\n", "from IPython.display import Image\n", "from IPython.core.display import HTML \n", "\n", "# The periodic table of elements with symbols, atomic numbers, and atomic masses\n", "Image(url= 'http://www.chem.qmul.ac.uk/iupac/AtWt/table.gif')\n", "\n", "# The periodic table of elements color-coded by type of element (metals, nonmetals, and metalloids)\n", "#Image(url= 'https://fthmb.tqn.com/I1J8fd6q-skC40aXr7LkJJN9Bew=/1500x1000/filters:fill(auto,1)/about/periodic-table-58ea5e0a5f9b58ef7ed0a788.jpg')\n", "\n", "# The periodic table of the elements with elemental families identified\n", "#Image(url= 'http://images.tutorcircle.com/cms/images/44/periodic-table11.PNG')\n" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Importing the Data into your Jupyter Notebook\n", "\n", ">The next 3 blocks of code imports the data and displays what information can be found in the data set." ] }, { "cell_type": "code", "execution_count": null, "metadata": { "collapsed": false }, "outputs": [], "source": [ "# Read in data that will be used for the calculations.\n", "# The data needs to be in the same directory(folder) as the program\n", "# Using pandas read_csv method, we can create a data frame\n", "#data = pd.read_csv(\"./data/elements.csv\")\n", "\n", "# If you're not using a Binder link, you can get the data with this instead:\n", "data = pd.read_csv(\"https://gist.githubusercontent.com/GoodmanSciences/c2dd862cd38f21b0ad36b8f96b4bf1ee/raw/1d92663004489a5b6926e944c1b3d9ec5c40900e/Periodic%2520Table%2520of%2520Elements.csv\")" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "collapsed": false }, "outputs": [], "source": [ "# displays a preview of the first several rows of the data set\n", "data.head(3)" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "collapsed": false }, "outputs": [], "source": [ "# shows you what data you can graph the names of all the columns in the dataset\n", "data.columns" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## PART 1: Trends Related to Atomic Number\n", "\n", ">Use and modify the section of code below to answer questions 3-5 in your coding booklet." ] }, { "cell_type": "code", "execution_count": null, "metadata": { "collapsed": false, "scrolled": true }, "outputs": [], "source": [ "ax = data.plot('AtomicNumber', 'AtomicMass', title=\"Trends Related to Atomic Number\", legend=False)\n", "ax.set(xlabel=\"Atomic Number\", ylabel=\"Comparison Factor\")" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## PART 2: The Periodicity of Element Properties\n", "\n", ">Use and modify the section of code below to answer questions 6 & 7 in your coding booklet." ] }, { "cell_type": "code", "execution_count": null, "metadata": { "collapsed": false, "scrolled": true }, "outputs": [], "source": [ "ax = data.plot('AtomicNumber', 'BoilingPoint', title=\"Looking for Periodicity of Properties\", legend=False)\n", "ax.set(xlabel=\"Atomic Number\", ylabel=\"Comparison Factor\")" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## PART 3: Unstructured Coding\n", "\n", ">Use and modify the section of code below to answer questions 8-11 in your coding booklet." ] }, { "cell_type": "code", "execution_count": null, "metadata": { "collapsed": false }, "outputs": [], "source": [ "data.Radioactive.count()" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "collapsed": false }, "outputs": [], "source": [ "# Set variables for scatter plot\n", "x = data.Group\n", "y = data.NumberofValence\n", "\n", "plt.scatter(x,y)\n", "plt.title('Looking For Patterns')\n", "plt.xlabel('x-axis')\n", "plt.ylabel('y-axis')\n", "\n", "#this sets the interval on the x-axis\n", "plt.xticks(np.arange(min(x), max(x)+1, 1.0))\n", "\n", "# This actually shows the plot\n", "plt.show()" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "collapsed": false, "scrolled": true }, "outputs": [], "source": [ "data[['AtomicNumber', 'Element', 'Type']].sort_values(by='AtomicNumber')\n" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ ">This data was modified from a data set that came from Data-Scientists [Matthew Renze](http://www.data-explorer.com/data). Thanks to UCF undergraduates Sam Borges, for finding the data set, and Lissa Galguera, for formatting it." ] } ], "metadata": { "anaconda-cloud": {}, "kernelspec": { "display_name": "Python 3", "language": "python", "name": "python3" }, "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.6.0" } }, "nbformat": 4, "nbformat_minor": 0 }