In [6]:
import dateutil.parser
import pandas as pd
import matplotlib.pyplot as plt

pd.set_option('display.mpl_style', 'default') # Make the graphs a bit prettier

dateparse = lambda x: dateutil.parser.parse(x)

In [7]:
melifero = pd.read_csv('../meliferopolis.csv', parse_dates=['timestamp'], dayfirst=True, date_parser=dateparse, index_col='timestamp')

In [8]:
melifero = melifero[:200]
melifero[:3]


Out[8]:
name value
timestamp
2014-07-04 13:05:01.974000+00:00 temperature_under_roof_center 23.240250
2014-07-04 13:05:01.973000+00:00 humidity 52.609914
2014-07-04 13:05:01.972000+00:00 global-weight 23.766336

In [9]:
melifero_temperature_under_roof_center = melifero[melifero.name == 'temperature_under_roof_center']
melifero_humidity = melifero[melifero.name == 'humidity']
melifero_global_weight = melifero[melifero.name == 'global-weight']


plt.figure()
melifero_global_weight['value'].plot(figsize=(15, 3))

plt.figure()
melifero_temperature_under_roof_center['value'].plot(figsize=(15, 3))

plt.figure()
melifero_humidity['value'].plot(figsize=(15, 3))


Out[9]:
<matplotlib.axes.AxesSubplot at 0x10810db90>

In [10]:
melifero.mean()


Out[10]:
value    34.068169
dtype: float64

In [11]:
melifero.resample('1H', how='mean')


Out[11]:
value
timestamp
2014-07-02 12:00:00+00:00 34.422468
2014-07-02 13:00:00+00:00 36.904114
2014-07-02 14:00:00+00:00 35.915634
2014-07-02 15:00:00+00:00 36.480638
2014-07-02 16:00:00+00:00 36.624242
2014-07-02 17:00:00+00:00 34.408762
2014-07-02 18:00:00+00:00 33.187352
2014-07-02 19:00:00+00:00 31.970922
2014-07-02 20:00:00+00:00 30.944490
2014-07-02 21:00:00+00:00 31.588502
2014-07-02 22:00:00+00:00 30.562254
2014-07-02 23:00:00+00:00 31.892056
2014-07-03 00:00:00+00:00 31.989092
2014-07-03 01:00:00+00:00 30.920236
2014-07-03 02:00:00+00:00 33.025496
2014-07-03 03:00:00+00:00 30.638436
2014-07-03 04:00:00+00:00 34.175700
2014-07-03 05:00:00+00:00 31.900170
2014-07-03 06:00:00+00:00 34.595578
2014-07-03 07:00:00+00:00 34.498386
2014-07-03 08:00:00+00:00 36.001054
2014-07-03 09:00:00+00:00 34.100426
2014-07-03 10:00:00+00:00 35.807802
2014-07-03 11:00:00+00:00 33.760542
2014-07-03 12:00:00+00:00 34.967740
2014-07-03 13:00:00+00:00 35.779700
2014-07-03 14:00:00+00:00 33.848448
2014-07-03 15:00:00+00:00 34.973832
2014-07-03 16:00:00+00:00 35.722160
2014-07-03 17:00:00+00:00 35.981548
2014-07-03 18:00:00+00:00 34.235414
2014-07-03 19:00:00+00:00 33.675156
2014-07-03 20:00:00+00:00 33.624146
2014-07-03 21:00:00+00:00 32.380460
2014-07-03 22:00:00+00:00 32.723662
2014-07-03 23:00:00+00:00 32.967494
2014-07-04 00:00:00+00:00 35.819578
2014-07-04 01:00:00+00:00 34.046410
2014-07-04 02:00:00+00:00 34.322516
2014-07-04 03:00:00+00:00 33.288626
2014-07-04 04:00:00+00:00 34.400308
2014-07-04 05:00:00+00:00 33.990656
2014-07-04 06:00:00+00:00 35.727600
2014-07-04 07:00:00+00:00 35.173452
2014-07-04 08:00:00+00:00 35.235924
2014-07-04 09:00:00+00:00 35.442016
2014-07-04 10:00:00+00:00 35.510440
2014-07-04 11:00:00+00:00 35.645654
2014-07-04 12:00:00+00:00 34.405678
2014-07-04 13:00:00+00:00 33.205500

In [13]:
melifero = pd.read_csv('../meliferopolis.csv', parse_dates=['timestamp'], dayfirst=True, date_parser=dateparse, index_col='timestamp')


melifero_global_weight = melifero[melifero.name == 'global-weight']
melifero_global_weight_mean = melifero_global_weight.resample('3H', how='mean')

melifero_temperature_under_roof_center = melifero[melifero.name == 'temperature_under_roof_center']
melifero_temperature_under_roof_center_mean = melifero_temperature_under_roof_center.resample('3H', how='mean')

melifero_humidity = melifero[melifero.name == 'humidity']
melifero_humidity_mean = melifero_humidity.resample('3H', how='mean')

In [14]:
melifero_global_weight_mean[:3]


Out[14]:
value
timestamp
2014-06-16 06:00:00+00:00 18.344832
2014-06-16 09:00:00+00:00 NaN
2014-06-16 12:00:00+00:00 NaN

In [16]:
plt.figure()
melifero_global_weight_mean['value'].plot(figsize=(15, 3))
plt.figure()
melifero_temperature_under_roof_center_mean['value'].plot(figsize=(15, 3))
plt.figure()
melifero_humidity_mean['value'].plot(figsize=(15, 3))


---------------------------------------------------------------------------
TypeError                                 Traceback (most recent call last)
<ipython-input-16-6cf6224f6bfd> in <module>()
      1 plt.figure()
----> 2 melifero_global_weight_mean['value'].plot(figsize=(15, 3))
      3 plt.figure()
      4 melifero_temperature_under_roof_center_mean['value'].plot(figsize=(15, 3))
      5 plt.figure()

/Library/Python/2.7/site-packages/pandas-0.12.0-py2.7-macosx-10.8-intel.egg/pandas/tools/plotting.pyc in plot_series(series, label, kind, use_index, rot, xticks, yticks, xlim, ylim, ax, style, grid, legend, logx, logy, secondary_y, **kwds)
   1728                      secondary_y=secondary_y, **kwds)
   1729 
-> 1730     plot_obj.generate()
   1731     plot_obj.draw()
   1732 

/Library/Python/2.7/site-packages/pandas-0.12.0-py2.7-macosx-10.8-intel.egg/pandas/tools/plotting.pyc in generate(self)
    854         self._compute_plot_data()
    855         self._setup_subplots()
--> 856         self._make_plot()
    857         self._post_plot_logic()
    858         self._adorn_subplots()

/Library/Python/2.7/site-packages/pandas-0.12.0-py2.7-macosx-10.8-intel.egg/pandas/tools/plotting.pyc in _make_plot(self)
   1238         if not self.x_compat and self.use_index and self._use_dynamic_x():
   1239             data = self._maybe_convert_index(self.data)
-> 1240             self._make_ts_plot(data, **self.kwds)
   1241         else:
   1242             lines = []

/Library/Python/2.7/site-packages/pandas-0.12.0-py2.7-macosx-10.8-intel.egg/pandas/tools/plotting.pyc in _make_ts_plot(self, data, **kwargs)
   1309             self._maybe_add_color(colors, kwds, style, 0)
   1310 
-> 1311             _plot(data, 0, ax, label, self.style, **kwds)
   1312         else:
   1313             for i, col in enumerate(data.columns):

/Library/Python/2.7/site-packages/pandas-0.12.0-py2.7-macosx-10.8-intel.egg/pandas/tools/plotting.pyc in _plot(data, col_num, ax, label, style, **kwds)
   1293         def _plot(data, col_num, ax, label, style, **kwds):
   1294             newlines = tsplot(data, plotf, ax=ax, label=label,
-> 1295                                 style=style, **kwds)
   1296             ax.grid(self.grid)
   1297             lines.append(newlines[0])

/Library/Python/2.7/site-packages/pandas-0.12.0-py2.7-macosx-10.8-intel.egg/pandas/tseries/plotting.pyc in tsplot(series, plotf, **kwargs)
     75         args.append(style)
     76 
---> 77     lines = plotf(ax, *args, **kwargs)
     78     label = kwargs.get('label', None)
     79 

/Library/Python/2.7/site-packages/matplotlib/axes.pyc in plot(self, *args, **kwargs)
   4135         lines = []
   4136 
-> 4137         for line in self._get_lines(*args, **kwargs):
   4138             self.add_line(line)
   4139             lines.append(line)

/Library/Python/2.7/site-packages/matplotlib/axes.pyc in _grab_next_args(self, *args, **kwargs)
    315                 return
    316             if len(remaining) <= 3:
--> 317                 for seg in self._plot_args(remaining, kwargs):
    318                     yield seg
    319                 return

/Library/Python/2.7/site-packages/matplotlib/axes.pyc in _plot_args(self, tup, kwargs)
    293             x = np.arange(y.shape[0], dtype=float)
    294 
--> 295         x, y = self._xy_from_xy(x, y)
    296 
    297         if self.command == 'plot':

/Library/Python/2.7/site-packages/matplotlib/axes.pyc in _xy_from_xy(self, x, y)
    212         if self.axes.xaxis is not None and self.axes.yaxis is not None:
    213             bx = self.axes.xaxis.update_units(x)
--> 214             by = self.axes.yaxis.update_units(y)
    215 
    216             if self.command != 'plot':

/Library/Python/2.7/site-packages/matplotlib/axis.pyc in update_units(self, data)
   1334         """
   1335 
-> 1336         converter = munits.registry.get_converter(data)
   1337         if converter is None:
   1338             return False

/Library/Python/2.7/site-packages/matplotlib/units.pyc in get_converter(self, x)
    135 
    136         if isinstance(x, np.ndarray) and x.size:
--> 137             xravel = x.ravel()
    138             try:
    139                 # pass the first value of x that is not masked back to

/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/numpy/ma/core.pyc in ravel(self)
   3961         r._update_from(self)
   3962         if self._mask is not nomask:
-> 3963             r._mask = ndarray.ravel(self._mask).reshape(r.shape)
   3964         else:
   3965             r._mask = nomask

/Library/Python/2.7/site-packages/pandas-0.12.0-py2.7-macosx-10.8-intel.egg/pandas/core/series.pyc in reshape(self, newshape, order)
    979             return self.values.reshape(newshape, order=order)
    980         else:
--> 981             return ndarray.reshape(self, newshape, order)
    982 
    983     def get(self, label, default=None):

TypeError: an integer is required

In [17]:
melifero_global_weight_mean.rename(columns={'value':'global_weight'}, inplace=True)
melifero_temperature_under_roof_center_mean.rename(columns={'value':'temperature_under_roof_center'}, inplace=True)
melifero_humidity_mean.rename(columns={'value':'humidity'}, inplace=True)

all = pd.merge(melifero_global_weight_mean, melifero_temperature_under_roof_center_mean,  right_index=True, left_index=True)
all = pd.merge(all, melifero_humidity_mean,  right_index=True, left_index=True)

all[:10]


Out[17]:
global_weight temperature_under_roof_center humidity
timestamp
2014-06-19 09:00:00+00:00 24.031392 30.042375 53.805150
2014-06-19 12:00:00+00:00 24.109536 25.690500 54.523854
2014-06-19 15:00:00+00:00 24.167616 27.095750 55.126680
2014-06-19 18:00:00+00:00 24.084192 12.936000 55.375362
2014-06-19 21:00:00+00:00 24.150720 15.006750 55.664406
2014-06-20 00:00:00+00:00 24.162336 12.276000 55.678077
2014-06-20 03:00:00+00:00 24.156000 16.128750 56.369439
2014-06-20 06:00:00+00:00 24.122208 32.995875 55.387080
2014-06-20 09:00:00+00:00 24.135936 31.890375 53.539542
2014-06-20 12:00:00+00:00 24.224640 27.794250 53.727030

In [18]:
from pandas.tools.plotting import scatter_matrix
scatter_matrix(all, alpha=0.8, figsize=(16, 16), diagonal='kde')


Out[18]:
array([[Axes(0.125,0.641667;0.258333x0.258333),
        Axes(0.383333,0.641667;0.258333x0.258333),
        Axes(0.641667,0.641667;0.258333x0.258333)],
       [Axes(0.125,0.383333;0.258333x0.258333),
        Axes(0.383333,0.383333;0.258333x0.258333),
        Axes(0.641667,0.383333;0.258333x0.258333)],
       [Axes(0.125,0.125;0.258333x0.258333),
        Axes(0.383333,0.125;0.258333x0.258333),
        Axes(0.641667,0.125;0.258333x0.258333)]], dtype=object)

In [ ]: