In [2]:
import agate
text = agate.Text()
number = agate.Number()
mean_temps = agate.Table.from_csv('mean_temp_65_15.csv')

In [3]:
print(mean_temps)


|----------------------+---------------|
|  column_names        | column_types  |
|----------------------+---------------|
|  Name                | Text          |
|   MeanAvgTemperature | Text          |
|   mcnt               | Number        |
|----------------------+---------------|


In [4]:
mean_temps_long = mean_temps.where(lambda row: row[' MeanAvgTemperature'] != 'M')
locations = ['Grand Island Area', 'North Platte Area', 'Lincoln Area', 'Norfolk Area', 'Omaha Area']
mean_locations = mean_temps_long.where(lambda row:row['Name'] in locations)
mean_locations.print_table()


|--------------------+---------------------+--------|
|  Name              |  MeanAvgTemperature |  mcnt  |
|--------------------+---------------------+--------|
|  Grand Island Area | 50.6                |     1  |
|  North Platte Area | 48.6                |     0  |
|  Lincoln Area      | 51.4                |     2  |
|  Norfolk Area      | 49.1                |     4  |
|  Omaha Area        | 51.1                |     2  |
|--------------------+---------------------+--------|

In [12]:
locations = ['Grand Island Area', 'North Platte Area', 'Lincoln Area', 'Norfolk Area', 'Omaha Area']
mean_temps4060 = agate.Table.from_csv('mean_temp_40_60.csv')
mean_locations4060 = mean_temps4060.where(lambda row:row['Name'] in locations)
mean_locations4060.print_table()
mean_temps6575 = agate.Table.from_csv('mean_temp_65_75.csv')
mean_locations6575 = mean_temps6575.where(lambda row:row['Name'] in locations)
mean_locations6575.print_table()
mean_temps7585 = agate.Table.from_csv('mean_temp_75_85.csv')
mean_locations7585 = mean_temps7585.where(lambda row:row['Name'] in locations)
mean_locations7585.print_table()
mean_temps8595 = agate.Table.from_csv('mean_temp_85_95.csv')
mean_locations8595 = mean_temps8595.where(lambda row:row['Name'] in locations)
mean_locations8595.print_table()
mean_temps9505 = agate.Table.from_csv('mean_temp_95_05.csv')
mean_locations9505 = mean_temps9505.where(lambda row:row['Name'] in locations)
mean_locations9505.print_table()
mean_temps0515 = agate.Table.from_csv('mean_temp_05_15.csv')
mean_locations0515 = mean_temps0515.where(lambda row:row['Name'] in locations)
mean_locations0515.print_table()


|--------+-------------------+---------------------+--------|
|   Year | Name              |  MeanAvgTemperature |  mcnt  |
|--------+-------------------+---------------------+--------|
|  1,940 | Grand Island Area | 50.5                |     0  |
|  1,940 | North Platte Area | 49.5                |     0  |
|  1,940 | Lincoln Area      | 51.6                |     2  |
|  1,940 | Norfolk Area      | M                   |   102  |
|  1,940 | Omaha Area        | 51.4                |     1  |
|--------+-------------------+---------------------+--------|
|--------+-------------------+---------------------+--------|
|   Year | Name              |  MeanAvgTemperature |  mcnt  |
|--------+-------------------+---------------------+--------|
|  1,965 | Grand Island Area | 50                  |     0  |
|  1,965 | North Platte Area | 47.6                |     0  |
|  1,965 | Lincoln Area      | 51.4                |     0  |
|  1,965 | Norfolk Area      | 48.1                |     1  |
|  1,965 | Omaha Area        | 51                  |     0  |
|--------+-------------------+---------------------+--------|
|--------+-------------------+---------------------+--------|
|   Year | Name              |  MeanAvgTemperature |  mcnt  |
|--------+-------------------+---------------------+--------|
|  1,975 | Grand Island Area | 49.8                |     0  |
|  1,975 | North Platte Area | 47.9                |     0  |
|  1,975 | Lincoln Area      | 50.5                |     2  |
|  1,975 | Norfolk Area      | 48.6                |     0  |
|  1,975 | Omaha Area        | 50.3                |     1  |
|--------+-------------------+---------------------+--------|
|--------+-------------------+---------------------+--------|
|   Year | Name              |  MeanAvgTemperature |  mcnt  |
|--------+-------------------+---------------------+--------|
|  1,985 | Grand Island Area | 50.9                |     0  |
|  1,985 | North Platte Area | 49.2                |     0  |
|  1,985 | Lincoln Area      | 51.7                |     0  |
|  1,985 | Norfolk Area      | 49.6                |     1  |
|  1,985 | Omaha Area        | 51.2                |     0  |
|--------+-------------------+---------------------+--------|
|--------+-------------------+---------------------+--------|
|   Year | Name              |  MeanAvgTemperature |  mcnt  |
|--------+-------------------+---------------------+--------|
|  1,995 | Grand Island Area | 51                  |     1  |
|  1,995 | North Platte Area | 49.2                |     0  |
|  1,995 | Lincoln Area      | 51.6                |     0  |
|  1,995 | Norfolk Area      | 49.6                |     0  |
|  1,995 | Omaha Area        | 51.4                |     1  |
|--------+-------------------+---------------------+--------|
|--------+-------------------+---------------------+--------|
|   Year | Name              |  MeanAvgTemperature |  mcnt  |
|--------+-------------------+---------------------+--------|
|  2,005 | Grand Island Area | 51.5                |     0  |
|  2,005 | North Platte Area | 49.3                |     0  |
|  2,005 | Lincoln Area      | 51.8                |     0  |
|  2,005 | Norfolk Area      | 49.7                |     2  |
|  2,005 | Omaha Area        | 51.8                |     0  |
|--------+-------------------+---------------------+--------|

In [13]:
total_temps = agate.Table.from_csv('mean_temp_total.csv')
mean_locations_total = total_temps.where(lambda row:row['Name'] in locations)

mean_locations_total.print_table()


|--------+-------------------+---------------------+--------|
|   Year | Name              |  MeanAvgTemperature |  mcnt  |
|--------+-------------------+---------------------+--------|
|  1,940 | Grand Island Area | 50.5                |     0  |
|  1,940 | North Platte Area | 49.5                |     0  |
|  1,940 | Lincoln Area      | 51.6                |     2  |
|  1,940 | Norfolk Area      | M                   |   102  |
|  1,940 | Omaha Area        | 51.4                |     1  |
|  1,965 | Grand Island Area | 50                  |     0  |
|  1,965 | North Platte Area | 47.6                |     0  |
|  1,965 | Lincoln Area      | 51.4                |     0  |
|  1,965 | Norfolk Area      | 48.1                |     1  |
|  1,965 | Omaha Area        | 51                  |     0  |
|  1,975 | Grand Island Area | 49.8                |     0  |
|  1,975 | North Platte Area | 47.9                |     0  |
|  1,975 | Lincoln Area      | 50.5                |     2  |
|  1,975 | Norfolk Area      | 48.6                |     0  |
|  1,975 | Omaha Area        | 50.3                |     1  |
|  1,985 | Grand Island Area | 50.9                |     0  |
|  1,985 | North Platte Area | 49.2                |     0  |
|  1,985 | Lincoln Area      | 51.7                |     0  |
|  1,985 | Norfolk Area      | 49.6                |     1  |
|  1,985 | Omaha Area        | 51.2                |     0  |
|  1,995 | Grand Island Area | 51                  |     1  |
|  1,995 | North Platte Area | 49.2                |     0  |
|  1,995 | Lincoln Area      | 51.6                |     0  |
|  1,995 | Norfolk Area      | 49.6                |     0  |
|  1,995 | Omaha Area        | 51.4                |     1  |
|  2,005 | Grand Island Area | 51.5                |     0  |
|  2,005 | North Platte Area | 49.3                |     0  |
|  2,005 | Lincoln Area      | 51.8                |     0  |
|  2,005 | Norfolk Area      | 49.7                |     2  |
|  2,005 | Omaha Area        | 51.8                |     0  |
|--------+-------------------+---------------------+--------|

In [15]:
import seaborn as sns
import matplotlib.pyplot as plt
import pandas as pd

sns.set(style="ticks", context='talk', font_scale=1)
%matplotlib inline

In [16]:
df = pd.read_csv('mean_temp_total.csv')

In [22]:
sns.set_style("white")
sns.tsplot(y=" MeanAvgTemperature", data=df);
plt.ylabel('')
plt.xlabel('Differences in Annual Temperatures Compared to 30 year average 1981-2010')
plt.xticks(rotation=90)
plt.autoscale(tight=True)
#ax = plt.gca()
#ax.get_xticks().get_major_formatter().scaled[365] = '%y'
sns.despine(bottom=True, left=True)


---------------------------------------------------------------------------
ValueError                                Traceback (most recent call last)
<ipython-input-22-043111d9df08> in <module>()
      1 sns.set_style("white")
----> 2 sns.tsplot(y=" MeanAvgTemperature", data=df);
      3 plt.ylabel('')
      4 plt.xlabel('Differences in Annual Temperatures Compared to 30 year average 1981-2010')
      5 plt.xticks(rotation=90)

/Users/lexieheinle/anaconda/envs/homework/lib/python3.5/site-packages/seaborn/timeseries.py in tsplot(data, time, unit, condition, value, err_style, ci, interpolate, color, estimator, n_boot, err_palette, err_kws, legend, ax, **kwargs)
    275     for c, (cond, df_c) in enumerate(data.groupby(condition, sort=False)):
    276 
--> 277         df_c = df_c.pivot(unit, time, value)
    278         x = df_c.columns.values.astype(np.float)
    279 

/Users/lexieheinle/anaconda/envs/homework/lib/python3.5/site-packages/pandas/core/frame.py in pivot(self, index, columns, values)
   3761         """
   3762         from pandas.core.reshape import pivot
-> 3763         return pivot(self, index=index, columns=columns, values=values)
   3764 
   3765     def stack(self, level=-1, dropna=True):

/Users/lexieheinle/anaconda/envs/homework/lib/python3.5/site-packages/pandas/core/reshape.py in pivot(self, index, columns, values)
    322         cols = [columns] if index is None else [index, columns]
    323         append = index is None
--> 324         indexed = self.set_index(cols, append=append)
    325         return indexed.unstack(columns)
    326     else:

/Users/lexieheinle/anaconda/envs/homework/lib/python3.5/site-packages/pandas/core/frame.py in set_index(self, keys, drop, append, inplace, verify_integrity)
   2778                 names.append(None)
   2779             else:
-> 2780                 level = frame[col]._values
   2781                 names.append(col)
   2782                 if drop:

/Users/lexieheinle/anaconda/envs/homework/lib/python3.5/site-packages/pandas/core/frame.py in __getitem__(self, key)
   1967             return self._getitem_multilevel(key)
   1968         else:
-> 1969             return self._getitem_column(key)
   1970 
   1971     def _getitem_column(self, key):

/Users/lexieheinle/anaconda/envs/homework/lib/python3.5/site-packages/pandas/core/frame.py in _getitem_column(self, key)
   1974         # get column
   1975         if self.columns.is_unique:
-> 1976             return self._get_item_cache(key)
   1977 
   1978         # duplicate columns & possible reduce dimensionality

/Users/lexieheinle/anaconda/envs/homework/lib/python3.5/site-packages/pandas/core/generic.py in _get_item_cache(self, item)
   1089         res = cache.get(item)
   1090         if res is None:
-> 1091             values = self._data.get(item)
   1092             res = self._box_item_values(item, values)
   1093             cache[item] = res

/Users/lexieheinle/anaconda/envs/homework/lib/python3.5/site-packages/pandas/core/internals.py in get(self, item, fastpath)
   3218                         loc = indexer.item()
   3219                     else:
-> 3220                         raise ValueError("cannot label index with a null key")
   3221 
   3222             return self.iget(loc, fastpath=fastpath)

ValueError: cannot label index with a null key

In [ ]: