Charting the Patterns of Elements
This data was modified from a data set that came from Data-Scientists Matthew Renze.
Thanks to UCF undergraduates Sam Borges, for finding the data set, and Lissa Galguera, for formatting it.
In [ ]:
# Import modules that contain functions we need
import pandas as pd
import numpy as np
%matplotlib inline
import matplotlib.pyplot as plt
In [ ]:
# This code imports the image of the periodic table from the URL below
#uncomment the image(url=... for the periodic table you would like to see. Be sure only one is uncommented at a time.
from IPython.display import Image
from IPython.core.display import HTML
# The periodic table of elements with symbols, atomic numbers, and atomic masses
Image(url= 'http://www.chem.qmul.ac.uk/iupac/AtWt/table.gif')
# The periodic table of elements color-coded by type of element (metals, nonmetals, and metalloids)
#Image(url= 'https://fthmb.tqn.com/I1J8fd6q-skC40aXr7LkJJN9Bew=/1500x1000/filters:fill(auto,1)/about/periodic-table-58ea5e0a5f9b58ef7ed0a788.jpg')
# The periodic table of the elements with elemental families identified
#Image(url= 'http://images.tutorcircle.com/cms/images/44/periodic-table11.PNG')
In [ ]:
# Read in data that will be used for the calculations.
# The data needs to be in the same directory(folder) as the program
# Using pandas read_csv method, we can create a data frame
#data = pd.read_csv("./data/elements.csv")
# If you're not using a Binder link, you can get the data with this instead:
data = pd.read_csv("https://gist.githubusercontent.com/GoodmanSciences/c2dd862cd38f21b0ad36b8f96b4bf1ee/raw/1d92663004489a5b6926e944c1b3d9ec5c40900e/Periodic%2520Table%2520of%2520Elements.csv")
In [ ]:
# displays a preview of the first several rows of the data set
data.head(3)
In [ ]:
# shows you what data you can graph the names of all the columns in the dataset
data.columns
In [ ]:
ax = data.plot('AtomicNumber', 'AtomicMass', title="Trends Related to Atomic Number", legend=False)
ax.set(xlabel="Atomic Number", ylabel="Comparison Factor")
In [ ]:
ax = data.plot('AtomicNumber', 'BoilingPoint', title="Looking for Periodicity of Properties", legend=False)
ax.set(xlabel="Atomic Number", ylabel="Comparison Factor")
In [ ]:
data.Radioactive.count()
In [ ]:
# Set variables for scatter plot
x = data.Group
y = data.NumberofValence
plt.scatter(x,y)
plt.title('Looking For Patterns')
plt.xlabel('x-axis')
plt.ylabel('y-axis')
#this sets the interval on the x-axis
plt.xticks(np.arange(min(x), max(x)+1, 1.0))
# This actually shows the plot
plt.show()
In [ ]:
data[['AtomicNumber', 'Element', 'Type']].sort_values(by='AtomicNumber')