Advertisement
MagicWinnie

Untitled

Mar 13th, 2020
215
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.76 KB | None | 0 0
  1. import numpy as np
  2. import pandas as pd
  3. import matplotlib.pyplot as plt
  4.  
  5.  
  6. path = "forecasts.csv"
  7.  
  8. df = pd.read_csv(path, encoding = "utf8")
  9.  
  10. gens = {
  11.     "Солнце 50%": 2,
  12.     "Ветер 50%": 2
  13. }
  14. cons = {
  15.     "Больницы 50%": 1,
  16.     "Заводы 50%": 2,
  17.     "Дома 50%": 3
  18. }
  19.  
  20. total_gen = 0
  21. total_con = 0
  22.  
  23.  
  24. array_gen = []
  25. array_con = []
  26.  
  27. for i in range(len(df)):
  28.     total_gen = 0
  29.     total_con = 0
  30.     for j in gens:
  31.         total_gen += gens[j]*df[j][i]
  32.     for j in cons:
  33.         total_con += cons[j]*df[j][i]
  34.     array_gen.append(total_gen)    
  35.     array_con.append(total_con)
  36.  
  37.  
  38. fig, ax = plt.subplots()
  39.  
  40. ax.plot(array_con, '-b', label="Consumed")
  41. ax.plot(array_gen, '-g', label="Generated")
  42. ax.legend()
  43.  
  44. plt.show()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement