import numpy as np
import pandas as pd
df=pd.read_csv("../input/pbd-load-history/PDB_Load_History.csv")
df
import missingno
# Plot graphic of missing values
missingno.matrix(df, figsize = (9,3))
# Let's write a little function to show us how many missing values
# there are
def find_missing_values(df, columns):
    """
    Finds number of rows where certain columns are missing values.
    ::param_df:: = target dataframe
    ::param_columns:: = list of columns
    """
    missing_vals = {}
    print("Number of missing or NaN values for each column:")
    df_length = len(df)
    for column in columns:
        total_column_values = df[column].value_counts().sum()
        missing_vals[column] = df_length-total_column_values
        #missing_vals.append(str(column)+ " column has {} missing or NaN values.".format())
    return missing_vals

missing_values = find_missing_values(df, columns=df.columns)
missing_values
temp=pd.DataFrame()
temp["date"]=df.date
temp["demand"]=df.demand
temp["temperature"]=df.temperature
temp=temp.groupby(["date"]).mean()
temp.reset_index(inplace=True)
temp.date=pd.to_datetime(temp.date, format='%m/%d/%Y')
temp=temp.sort_values(by=['date'],ascending=True)
temp.reset_index(inplace=True)
temp.drop("index",axis=1,inplace=True)
temp
import matplotlib.pyplot as plt
from matplotlib.pyplot import figure

figure(figsize=(30, 10))
date = temp.date.to_list()
demand = temp.demand.to_list()
temperature = temp.temperature.to_list()
x=[]
dim=[]
tmp=[]
for i in range (2003,2015):
    xx=[]
    xxx=[]
    dimm=[]
    tmpp=[]
    #index=0
    for j in range (len(demand)):
        if date[j].year==i:
            xx.append(date[j].strftime("%m/%d/%Y")[0:-5])
            #xxx.append(index)
            dimm.append(demand[j])
            tmpp.append(temperature[j])
        #index+=1
    #index=0
    x.append(xx)
    dim.append(dimm)
    tmp.append(tmpp)
#print(x[4])
'''plt.plot(x[0], dim[0], label = "demand 2003")
plt.plot(x[1], dim[1], label = "demand 2004")
plt.plot(x[2], dim[2], label = "demand 2005")
plt.plot(x[3], dim[3], label = "demand 2006")
plt.plot(x[4], dim[4], label = "demand 2007")
plt.plot(x[5], dim[5], label = "demand 2008")
plt.plot(x[6], dim[6], label = "demand 2009")
plt.plot(x[7], dim[7], label = "demand 2010")
plt.plot(x[8], dim[8], label = "demand 2011")
plt.plot(x[9], dim[9], label = "demand 2012")
plt.plot(x[10], dim[10], label = "demand 2013")
plt.plot(x[11], dim[11], label = "demand 2014")'''
for i in range(2003,2015):
    label="demand "+str(i)
    plt.plot(x[i-2003], dim[i-2003], label = label)
#plt.plot(x[i-2003], tmp[i-2003], label = label2)
plt.legend()
plt.show()
"""
##### 
"""