In [1]:
# Libraries
import pandas as pd
import matplotlib.pyplot as plt
import matplotlib
matplotlib.style.use('ggplot')
import random as rng
import numpy as np
%matplotlib inline

In [38]:
data = pd.read_csv("ocr.csv")

In [52]:
data.head()


Out[52]:
2016 2016.1 Unnamed: 2 2015 Unnamed: 4 Unnamed: 5 2014 Unnamed: 7 Unnamed: 8 2013 ... Unnamed: 16 Unnamed: 17 2010 Unnamed: 19 Unnamed: 20 2009 Unnamed: 22 Unnamed: 23 2008 Unnamed: 25
0 Toronto Fingerlakes NaN Team OPR Rank NaN Team OPR Rank NaN Team ... OPR Rank NaN Team OPR Rank NaN Team OPR Rank NaN Team OPR Rank
1 118 20 NaN 1 229 NaN 1 1207 NaN 1 ... 330 NaN 1 53 NaN 1 317 NaN 1 161
2 296 73 NaN 4 1085 NaN 4 1404 NaN 4 ... 1338 NaN 4 364 NaN 4 436 NaN 4 1242
3 610 174 NaN 8 1969 NaN 8 1262 NaN 8 ... 1159 NaN 7 572 NaN 7 328 NaN 5 197
4 746 191 NaN 11 231 NaN 11 410 NaN 11 ... 946 NaN 8 234 NaN 8 1041 NaN 7 1208

5 rows × 26 columns


In [47]:
# make individual dataframes for each year
df_2015 = data[['2015','Unnamed: 4']]
df_2014 = data[['2014','Unnamed: 7']]
df_2013 = data[['2013','Unnamed: 4']]

df_2015.head()


Out[47]:
2015 Unnamed: 4
0 Team OPR Rank
1 1 229
2 4 1085
3 8 1969
4 11 231

In [37]:
plt.boxplot(data["Unnamed: 3"][1:])
plt.show()


---------------------------------------------------------------------------
KeyError                                  Traceback (most recent call last)
<ipython-input-37-d225a414cad2> in <module>()
----> 1 plt.boxplot(data["Unnamed: 3"][1:])
      2 plt.show()

/Users/dinbecevic/anaconda/lib/python2.7/site-packages/matplotlib/pyplot.pyc in boxplot(x, notch, sym, vert, whis, positions, widths, patch_artist, bootstrap, usermedians, conf_intervals, meanline, showmeans, showcaps, showbox, showfliers, boxprops, labels, flierprops, medianprops, meanprops, capprops, whiskerprops, manage_xticks, hold, data)
   2708                          meanprops=meanprops, capprops=capprops,
   2709                          whiskerprops=whiskerprops,
-> 2710                          manage_xticks=manage_xticks, data=data)
   2711     finally:
   2712         ax.hold(washold)

/Users/dinbecevic/anaconda/lib/python2.7/site-packages/matplotlib/__init__.pyc in inner(ax, *args, **kwargs)
   1809                     warnings.warn(msg % (label_namer, func.__name__),
   1810                                   RuntimeWarning, stacklevel=2)
-> 1811             return func(ax, *args, **kwargs)
   1812         pre_doc = inner.__doc__
   1813         if pre_doc is None:

/Users/dinbecevic/anaconda/lib/python2.7/site-packages/matplotlib/axes/_axes.pyc in boxplot(self, x, notch, sym, vert, whis, positions, widths, patch_artist, bootstrap, usermedians, conf_intervals, meanline, showmeans, showcaps, showbox, showfliers, boxprops, labels, flierprops, medianprops, meanprops, capprops, whiskerprops, manage_xticks)
   3206             bootstrap = rcParams['boxplot.bootstrap']
   3207         bxpstats = cbook.boxplot_stats(x, whis=whis, bootstrap=bootstrap,
-> 3208                                        labels=labels)
   3209         if notch is None:
   3210             notch = rcParams['boxplot.notch']

/Users/dinbecevic/anaconda/lib/python2.7/site-packages/matplotlib/cbook.pyc in boxplot_stats(X, whis, bootstrap, labels)
   1969 
   1970     # convert X to a list of lists
-> 1971     X = _reshape_2D(X)
   1972 
   1973     ncols = len(X)

/Users/dinbecevic/anaconda/lib/python2.7/site-packages/matplotlib/cbook.pyc in _reshape_2D(X)
   2217         # one item
   2218         if len(X.shape) == 1:
-> 2219             if hasattr(X[0], 'shape'):
   2220                 X = list(X)
   2221             else:

/Users/dinbecevic/anaconda/lib/python2.7/site-packages/pandas/core/series.pyc in __getitem__(self, key)
    555     def __getitem__(self, key):
    556         try:
--> 557             result = self.index.get_value(self, key)
    558 
    559             if not np.isscalar(result):

/Users/dinbecevic/anaconda/lib/python2.7/site-packages/pandas/core/index.pyc in get_value(self, series, key)
   1788 
   1789         try:
-> 1790             return self._engine.get_value(s, k)
   1791         except KeyError as e1:
   1792             if len(self) > 0 and self.inferred_type in ['integer','boolean']:

pandas/index.pyx in pandas.index.IndexEngine.get_value (pandas/index.c:3204)()

pandas/index.pyx in pandas.index.IndexEngine.get_value (pandas/index.c:2903)()

pandas/index.pyx in pandas.index.IndexEngine.get_loc (pandas/index.c:3843)()

pandas/hashtable.pyx in pandas.hashtable.Int64HashTable.get_item (pandas/hashtable.c:6525)()

pandas/hashtable.pyx in pandas.hashtable.Int64HashTable.get_item (pandas/hashtable.c:6463)()

KeyError: 0