Browse Source

Further optimisations

Petra Lamborn 5 years ago
parent
commit
3148bc89da
2 changed files with 5 additions and 2 deletions
  1. 4
    1
      py/downkwh.py
  2. 1
    1
      py/util.py

+ 4
- 1
py/downkwh.py View File

@@ -19,9 +19,12 @@ for i, m in enumerate(months):
19 19
                      '2017-{:02d}-01 00:30:00'.format(mstarts[i]), 
20 20
                      '2017-{:02d}-01 00:00:00'.format(mends[i]), 
21 21
                      '%%1')
22
+    print("Pivoting")
23
+    kwhpiv = kwhdata.pivot(index = 'read_time', columns = 'icp_id', values = 'kwh_tot')
22 24
     print("Pickling")
23
-    kwhdata.to_pickle('../data/2017-{}-all.pkl'.format(m))
25
+    kwhpiv.to_pickle('../data/2017-{}-all.pkl'.format(m))
24 26
     del kwhdata
27
+    del kwhpiv
25 28
     gc.collect()
26 29
 
27 30
 print('Done')

+ 1
- 1
py/util.py View File

@@ -116,7 +116,7 @@ def getkwh(datestart, dateend, timestart, timeend, subset):
116 116
     qdf = getQuery(query, pdict)
117 117
     print("Optimising")
118 118
     qdf['icp_id'] = qdf['icp_id'].astype(np.int32)
119
-    qdf['kwh_tot'] = qdf['kwh_tot'].astype(np.float32)
119
+    qdf['kwh_tot'] = qdf['kwh_tot'].astype(np.float16)
120 120
     print("Done")
121 121
     return(qdf)
122 122