In [432]:
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 [433]:
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 [434]:
del lamine['name']
lamine.rename(columns={'value':'global_weight'}, inplace=True)

In [435]:
# lamine = lamine['2014-06-29':'2014-07-03']
lamine = lamine.resample('1H', how='mean')

#meteobdx = meteobdx['2014-06-29':'2014-07-03']
meteobdx = meteobdx.resample('1H', how='mean')

In [436]:
#lamine.tail(24)

In [452]:
all = pd.merge(meteobdx, lamine,  right_index=True, left_index=True)
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.tail()


Out[452]:
temp hum precipm pressurem wspdm wdird vism fog rain snow hail thunder tornado global_weight corrected_weight time-copy hour
timestamp
2014-07-04 10:00:00+00:00 23.0 64.5 -9999 1013.0 15.75 250 25 0 0.5 0 0 0.5 0 59.753590 36.753590 2014-07-04 10:00:00 10
2014-07-04 11:00:00+00:00 21.5 84.5 -9999 1013.5 7.45 295 10 0 0.5 0 0 0.0 0 60.387179 38.887179 2014-07-04 11:00:00 11
2014-07-04 12:00:00+00:00 23.5 70.5 -9999 1013.0 14.80 300 10 0 0.5 0 0 0.0 0 60.296923 36.796923 2014-07-04 12:00:00 12
2014-07-04 13:00:00+00:00 23.5 66.5 -9999 1013.0 22.25 260 10 0 0.0 0 0 0.0 0 60.596154 37.096154 2014-07-04 13:00:00 13
2014-07-04 14:00:00+00:00 23.5 67.5 -9999 1013.5 23.15 260 10 0 0.5 0 0 0.0 0 60.522308 37.022308 2014-07-04 14:00:00 14

In [460]:
pivot = all.pivot(index='time-copy', columns='hour', values='corrected_weight')

In [462]:
pivot.resample('1D', how='mean').to_csv('../dataviz/3d/3d.csv')

In [397]:


In [ ]: