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]:
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]:
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]:
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]:
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]:
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()
In [304]:
t = all.index[0]
In [305]:
t.value
Out[305]:
In [ ]: