Last active
February 14, 2018 06:05
-
-
Save misterhay/6f025d7fa5eb92719ae7c2431ab4e6e1 to your computer and use it in GitHub Desktop.
experimenting with Panada and Plotly offline in Jupyter for visualizing open data
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import pandas as pd | |
import plotly | |
from plotly.graph_objs import Scatter, Layout | |
plotly.offline.init_notebook_mode(connected=True) | |
plo = plotly.offline.iplot | |
results = pd.read_excel('https://education.alberta.ca/media/3680582/diploma-multiyear-auth-list-annual.xlsx') | |
years = [] | |
for value in results.columns.values: | |
try: # check if first four digits are a number (a year) | |
year = value[0:4] | |
int(year) | |
if year not in years: | |
years.append(year) | |
except (TypeError, ValueError): | |
pass | |
schoolAuthority = 'Elk Island Public Schools Regional Division No. 14' | |
interestingRows = [] | |
for row in results.iterrows(): | |
if row[1]['Authority Name'] == schoolAuthority: | |
rowNumber = row[0] | |
interestingRows.append(rowNumber) | |
lookingFor = 'Auth School Mark % Exc' | |
x = years | |
y = [] | |
for rowNumber in interestingRows: | |
for year in years: | |
findThis = year + ' ' + lookingFor | |
y.append(results.iloc[rowNumber][findThis]) | |
plo({ | |
"data": [Scatter(x=x, y=y)], | |
"layout": Layout( | |
yaxis=dict(range=[0,100]), | |
title=results.iloc[rowNumber]['Diploma Course'] + '<br>' + lookingFor + '<br>' + schoolAuthority | |
) | |
}) | |
y = [] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment