|
@@ -2,6 +2,7 @@ import psycopg2 as pg
|
2
|
2
|
from configparser import ConfigParser
|
3
|
3
|
import pandas.io.sql as psql
|
4
|
4
|
import datetime as dt
|
|
5
|
+import numpy as np
|
5
|
6
|
|
6
|
7
|
|
7
|
8
|
def config(filename='database.ini', section='postgresql'):
|
|
@@ -67,7 +68,7 @@ def pickleQuery(query, path, qparams=[]):
|
67
|
68
|
|
68
|
69
|
def getkwh(datestart, dateend, timestart, timeend, subset):
|
69
|
70
|
query = """
|
70
|
|
- SELECT comb.icp_id, comb.read_time, COALESCE(kwh_tot, 0) AS kwh_tot
|
|
71
|
+ SELECT SUBSTRING(comb.icp_id FROM 2 FOR 6)::int AS icp_id, comb.read_time, COALESCE(kwh_tot, 0) AS kwh_tot
|
71
|
72
|
FROM
|
72
|
73
|
(
|
73
|
74
|
SELECT read_time, icp_id
|
|
@@ -123,6 +124,9 @@ def getkwh(datestart, dateend, timestart, timeend, subset):
|
123
|
124
|
print("Getting data with parameters:")
|
124
|
125
|
print(pdict)
|
125
|
126
|
qdf = getQuery(query, pdict)
|
|
127
|
+ print("Optimising")
|
|
128
|
+ qdf['icp_id'] = qdf['icp_id'].astype(np.int32)
|
|
129
|
+ qdf['kwh_tot'] = qdf['kwh_tot'].astype(np.float32)
|
126
|
130
|
print("Done")
|
127
|
131
|
return(qdf)
|
128
|
132
|
|