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]:
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 [ ]: