In [307]:
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 [308]:
meliferopolis = pd.read_csv('../meliferopolis.csv', parse_dates=['timestamp'], dayfirst=True, date_parser=dateparse, index_col='timestamp')
lamine = pd.read_csv('../lamine.csv', parse_dates=['timestamp'], dayfirst=True, date_parser=dateparse, index_col='timestamp')
meteobdx =  pd.read_csv('../meteowunderbordeaux.csv', parse_dates=['timestamp'], dayfirst=True, date_parser=dateparse, index_col='timestamp')

In [309]:
del lamine['name']
lamine.rename(columns={'value':'global_weight'}, inplace=True)

In [310]:
lamine = lamine.resample('1H', how='mean')
meteobdx = meteobdx.resample('1H', how='mean')

In [313]:
all = pd.merge(meteobdx, lamine,  right_index=True, left_index=True)
all.head()


Out[313]:
temp hum precipm pressurem wspdm wdird vism fog rain snow hail thunder tornado global_weight
timestamp
2014-05-27 22:00:00+00:00 10.5 80.5 -9999 1017.5 0.00 0 10.0 0 0 0 0 0 0 41.193846
2014-05-27 23:00:00+00:00 10.0 86.0 -9999 1017.5 0.95 5 10.0 0 0 0 0 0 0 41.184615
2014-05-28 00:00:00+00:00 9.0 92.5 -9999 1017.0 1.85 230 10.0 0 0 0 0 0 0 41.403077
2014-05-28 01:00:00+00:00 8.0 92.0 -9999 1016.5 2.80 240 10.0 0 0 0 0 0 0 41.646154
2014-05-28 02:00:00+00:00 8.0 94.0 -9999 1016.0 0.00 0 22.5 0 0 0 0 0 0 41.178462

In [314]:
all["corrected_weight"] = all.apply(lambda x: x[13] - x[0], axis=1)
all['time-copy'] = all.index 
all["hour"] = all.apply(lambda x: x['time-copy'].hour, axis=1)
all["hour-minute"] = all.apply(lambda x: x['time-copy'].hour * 60  + x['time-copy'].minute, axis=1)

In [315]:
all['2014-06-19':'2014-07-03']["corrected_weight"].plot(figsize=(15, 3))
all['2014-06-19':'2014-07-03']["hum"].plot(figsize=(15, 3))


Out[315]:
<matplotlib.axes.AxesSubplot at 0x114720950>

In [316]:
# from pandas.tools.plotting import scatter_matrix
# scatter_matrix(all, alpha=0.8, figsize=(10, 10), diagonal='kde')
plt.scatter(all['hour-minute'], all['corrected_weight'], s=120)


Out[316]:
<matplotlib.collections.PathCollection at 0x114b15850>

In [278]:
plt.figure()
plt.scatter(all['2014-06-01':'2014-07-04']['hum'],all['2014-06-01':'2014-07-04']['corrected_weight'], s=30)


Out[278]:
<matplotlib.collections.PathCollection at 0x1148db590>

In [271]:
df = pd.DataFrame(all['corrected_weight'], index=all.index)
df['global_weight'] = all['global_weight']
df['hum'] = all['hum']
df['temp'] = all['temp']

In [282]:


In [273]:
all['2014-06-19':'2014-07-03']["corrected_weight"].plot(figsize=(15, 3))
all['2014-06-19':'2014-07-03']["hum"].plot(figsize=(15, 3))


Out[273]:
<matplotlib.axes.AxesSubplot at 0x114cbc8d0>

In [279]:
from mpl_toolkits.mplot3d import Axes3D

In [302]:
import matplotlib.pyplot as plt
import numpy as np

In [306]:
import time as time
xpos = [0]
ypos = all.index
zpos = all['corrected_weight']

dx = 1
dy = 1
dz = [2, 3]

# Move each (x, y) coordinate to center it on the tick

xpos = map(lambda x: x - 0.5, xpos)
ypos = map(lambda y: y.value - 0.5, ypos)

fig = plt.figure()
ax = plt.axes(projection='3d')
ax.bar3d(xpos, ypos, zpos, dx, dy, dz)

# Do not print years in exponential notation

y_formatter = matplotlib.ticker.ScalarFormatter(useOffset=False)
ax.yaxis.set_major_formatter(y_formatter)

plt.show()


/Library/Python/2.7/site-packages/mpl_toolkits/mplot3d/axes3d.py:2307: UserWarning: x, y, and z must be the same length.
  warnings.warn('x, y, and z must be the same length.')

In [304]:
t = all.index[0]

In [305]:
t.value


Out[305]:
1401228000000000000

In [ ]: