# Import modules that contain functions we need
import pandas as pd
import numpy as np
%matplotlib inline
import matplotlib.pyplot as plt

"""
Explanation: Periodic Trends
Charting the Patterns of Elements
Step 1 - Creating a Checkpoint

Create a checkpoint by clicking <b>File</b> ==> <b>Save and Checkpoint</b>. If you make a major mistake, you can click <u>File</u> ==> <u>Revert to Checkpoint</u> to reset the Jupyter Notebook online on Binder.org.
End of explanation
"""


# 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')


"""
Explanation: Pre-Questions

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 <b> Shift + Enter </b> to display another image.
End of explanation
"""


# 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")

# displays a preview of the first several rows of the data set
data.head(3)

# shows you what data you can graph the names of all the columns in the dataset
data.columns

"""
Explanation: Importing the Data into your Jupyter Notebook

The next 3 blocks of code imports the data and displays what information can be found in the data set.
End of explanation
"""


ax = data.plot('AtomicNumber', 'AtomicMass', title="Trends Related to Atomic Number", legend=False)
ax.set(xlabel="Atomic Number", ylabel="Comparison Factor")

"""
Explanation: PART 1: Trends Related to Atomic Number

Use and modify the section of code below to answer questions 3-5 in your coding booklet.
End of explanation
"""


ax = data.plot('AtomicNumber', 'BoilingPoint', title="Looking for Periodicity of Properties", legend=False)
ax.set(xlabel="Atomic Number", ylabel="Comparison Factor")

"""
Explanation: PART 2: The Periodicity of Element Properties

Use and modify the section of code below to answer questions 6 & 7 in your coding booklet.
End of explanation
"""


data.Radioactive.count()

# 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()

data[['AtomicNumber', 'Element', 'Type']].sort_values(by='AtomicNumber')


"""
Explanation: PART 3: Unstructured Coding

Use and modify the section of code below to answer questions 8-11 in your coding booklet.
End of explanation
"""


