Repository for Petra's work at ampli Jan-Feb 2019

clustering.py 762B

12345678910111213141516171819202122232425262728293031323334
  1. from util import getQuery
  2. import pandas as p
  3. import matplotlib.pyplot as plt
  4. import seaborn as sns
  5. # query = """
  6. # SELECT *, read_date + CONCAT(period / 2, ':', period %% 2 * 30, ':00')::time AS read_time
  7. # FROM public.coup_tall_april WHERE icp_id LIKE (%s) AND read_date = to_date(%s, 'dd/mm/yyyy')
  8. # ORDER BY icp_id, read_time;
  9. # """
  10. #
  11. # qparams = ['%%1117', '20/04/2017']
  12. query = """
  13. SELECT read_date, period, AVG(kwh_tot) AS average
  14. FROM public.coup_tall_april
  15. GROUP BY read_date, period
  16. ORDER BY read_date, period;
  17. """
  18. qparams = []
  19. df = getQuery(query, qparams)
  20. print(df.info())
  21. sns.set()
  22. #sns.lineplot(x = 'read_time', y = 'kwh_tot', hue = 'icp_id', data = df)
  23. sns.lineplot(x = 'period', y = 'average', hue = 'read_date', data = df)
  24. plt.show()