123456789101112131415161718192021222324252627282930313233 |
- from util import getQuery, pickleQuery, getkwh
- import pandas as p
- import gc
- from datetime import datetime
- from tqdm import tqdm
-
- months = ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec']
- mstarts = list(range(1, 13))
- mends = mstarts[1:13]
- mends.append(1)
- yends = [2017] * 11
- yends.append(2018)
-
- for i, m in tqdm(enumerate(months)):
- # if i < 11:
- # continue
- print(m)
- print(datetime.now().time())
- kwhdata = getkwh('2017-{:02d}-01'.format(mstarts[i]),
- '{}-{:02d}-01'.format(yends[i], mends[i]),
- '2017-{:02d}-01 00:30:00'.format(mstarts[i]),
- '{}-{:02d}-01 00:00:00'.format(yends[i], mends[i]),
- '%%1')
- print("Pivoting")
- kwhpiv = kwhdata.pivot(index = 'read_time', columns = 'icp_id', values = 'kwh_tot')
- print("Pickling")
- kwhpiv.to_pickle('../data/2017-{}-5k.pkl'.format(m))
- del kwhdata
- del kwhpiv
- gc.collect()
-
- print('Done')
|