In [22]:
import matplotlib.pyplot as plt
import pandas as pd
from pandas.tools.plotting import scatter_matrix
from io import StringIO
import numpy as np
import datetime
import os
import glob
In [23]:
path='./'
In [71]:
#Import ALL csv files into dataframe
allFiles = glob.glob(path + "/*.csv")
frame = pd.DataFrame()
list_ = []
for file_ in allFiles:
df = pd.read_csv(file_,index_col=None, header=0,skiprows=range(1, 3))
list_.append(df)
frame = pd.concat(list_);
len(list_) #len(list_) = number of coaches
Out[71]:
In [87]:
frame=frame.fillna(0); #Replace NaN with zeros.
print frame.head(3)
len(frame)
Out[87]:
In [144]:
print allFiles #Order of coaches' files
start_col=3; #first week of work starts at column number "start_col"
#week 1: col 3 and 4.
#week 2: col 5 and 6
# ...
#week n: start_col+2*n and (start_col+2*n)+1
start_row=0;
end_row=8;
increment=8; #Next coach
frame.iloc[start_row:end_row,start_col] #Entire week's per day "expected hours"
frame.iloc[start_row:end_row, start_col+1] #Entire week's per day "actual hours"
print frame.iloc[start_row:end_row, start_col].iloc[-1] #Last entry in column of "Actual hours"
print frame.iloc[start_row:end_row, start_col+1].iloc[-1] #Last entry in column of "Actual hours
print 'current row...', start_row, 'coach...', allFiles[start_row/increment]
start_row=start_row+increment;
end_row = end_row + increment;
frame.iloc[start_row+increment:end_row+increment,start_col] #Prints the entire week's per day expected hours
frame.iloc[start_row+increment:end_row+increment, start_col+1] #Prints the entire week's per day actual hours
print frame.iloc[start_row:end_row, start_col].iloc[-1] #Last entry in column of "Actual hours"
print frame.iloc[start_row:end_row, start_col+1].iloc[-1] #Last entry in column of "Actual hours
print 'current row...', start_row, 'coach...', allFiles[start_row/increment]
start_row=start_row+increment;
end_row = end_row + increment;
frame.iloc[start_row+increment:end_row+increment,start_col] #Prints the entire week's per day expected hours
frame.iloc[start_row+increment:end_row+increment, start_col+1] #Prints the entire week's per day actual hours
print frame.iloc[start_row:end_row, start_col].iloc[-1] #Last entry in column of "Actual hours"
print frame.iloc[start_row:end_row, start_col+1].iloc[-1] #Last entry in column of "Actual hours
print 'current row...', start_row, 'coach...', allFiles[start_row/increment]
start_row=start_row+increment;
end_row = end_row + increment;
frame.iloc[start_row+increment:end_row+increment,start_col] #Prints the entire week's per day expected hours
frame.iloc[start_row+increment:end_row+increment, start_col+1] #Prints the entire week's per day actual hours
print frame.iloc[start_row:end_row, start_col].iloc[-1] #Last entry in column of "Actual hours"
print frame.iloc[start_row:end_row, start_col+1].iloc[-1] #Last entry in column of "Actual hours
print 'current row...', start_row, 'coach...', allFiles[start_row/increment]
start_row=start_row+increment;
end_row = end_row + increment;
frame.iloc[start_row+increment:end_row+increment,start_col] #Prints the entire week's per day expected hours
frame.iloc[start_row+increment:end_row+increment, start_col+1] #Prints the entire week's per day actual hours
print frame.iloc[start_row:end_row, start_col].iloc[-1] #Last entry in column of "Actual hours"
print frame.iloc[start_row:end_row, start_col+1].iloc[-1] #Last entry in column of "Actual hours
print 'current row...', start_row, 'coach...', allFiles[start_row/increment]
start_row=start_row+increment;
end_row = end_row + increment;
frame.iloc[start_row+increment:end_row+increment,start_col] #Prints the entire week's per day expected hours
frame.iloc[start_row+increment:end_row+increment, start_col+1] #Prints the entire week's per day actual hours
print frame.iloc[start_row:end_row, start_col].iloc[-1] #Last entry in column of "Actual hours"
print frame.iloc[start_row:end_row, start_col+1].iloc[-1] #Last entry in column of "Actual hours
print 'current row...', start_row, 'coach...', allFiles[start_row/increment]
start_row=start_row+increment;
end_row = end_row + increment;
frame.iloc[start_row+increment:end_row+increment,start_col] #Prints the entire week's per day expected hours
frame.iloc[start_row+increment:end_row+increment, start_col+1] #Prints the entire week's per day actual hours
print frame.iloc[start_row:end_row, start_col].iloc[-1] #Last entry in column of "Actual hours"
print frame.iloc[start_row:end_row, start_col+1].iloc[-1] #Last entry in column of "Actual hours
print 'current row...', start_row, 'coach...', allFiles[start_row/increment]
start_row=start_row+increment;
end_row = end_row + increment;
frame.iloc[start_row+increment:end_row+increment,start_col] #Prints the entire week's per day expected hours
frame.iloc[start_row+increment:end_row+increment, start_col+1] #Prints the entire week's per day actual hours
print frame.iloc[start_row:end_row, start_col].iloc[-1] #Last entry in column of "Actual hours"
print frame.iloc[start_row:end_row, start_col+1].iloc[-1] #Last entry in column of "Actual hours
print 'current row...', start_row, 'coach...', allFiles[start_row/increment]
start_row=start_row+increment;
end_row = end_row + increment;
frame.iloc[start_row+increment:end_row+increment,start_col] #Prints the entire week's per day expected hours
frame.iloc[start_row+increment:end_row+increment, start_col+1] #Prints the entire week's per day actual hours
print frame.iloc[start_row:end_row, start_col].iloc[-1] #Last entry in column of "Actual hours"
print frame.iloc[start_row:end_row, start_col+1].iloc[-1] #Last entry in column of "Actual hours
print 'current row...', start_row, 'coach...', allFiles[start_row/increment]
start_row=start_row+increment;
end_row = end_row + increment;
frame.iloc[start_row+increment:end_row+increment,start_col] #Prints the entire week's per day expected hours
frame.iloc[start_row+increment:end_row+increment, start_col+1] #Prints the entire week's per day actual hours
print frame.iloc[start_row:end_row, start_col].iloc[-1] #Last entry in column of "Actual hours"
print frame.iloc[start_row:end_row, start_col+1].iloc[-1] #Last entry in column of "Actual hours
print 'current row...', start_row, 'coach...', allFiles[start_row/increment]
start_row=start_row+increment;
end_row = end_row + increment;
frame.iloc[start_row+increment:end_row+increment,start_col] #Prints the entire week's per day expected hours
frame.iloc[start_row+increment:end_row+increment, start_col+1] #Prints the entire week's per day actual hours
print frame.iloc[start_row:end_row, start_col].iloc[-1] #Last entry in column of "Actual hours"
print frame.iloc[start_row:end_row, start_col+1].iloc[-1] #Last entry in column of "Actual hours
print 'current row...', start_row, 'coach...', allFiles[start_row/increment]
start_row=start_row+increment;
end_row = end_row + increment;
frame.iloc[start_row+increment:end_row+increment,start_col] #Prints the entire week's per day expected hours
frame.iloc[start_row+increment:end_row+increment, start_col+1] #Prints the entire week's per day actual hours
print frame.iloc[start_row:end_row, start_col].iloc[-1] #Last entry in column of "Actual hours"
print frame.iloc[start_row:end_row, start_col+1].iloc[-1] #Last entry in column of "Actual hours
print 'current row...', start_row, 'coach...', allFiles[start_row/increment]
start_row=start_row+increment;
end_row = end_row + increment;
frame.iloc[start_row+increment:end_row+increment,start_col] #Prints the entire week's per day expected hours
frame.iloc[start_row+increment:end_row+increment, start_col+1] #Prints the entire week's per day actual hours
print frame.iloc[start_row:end_row, start_col].iloc[-1] #Last entry in column of "Actual hours"
print frame.iloc[start_row:end_row, start_col+1].iloc[-1] #Last entry in column of "Actual hours
print 'current row...', start_row, 'coach...', allFiles[start_row/increment]
start_row=start_row+increment;
end_row = end_row + increment;
frame.iloc[start_row+increment:end_row+increment,start_col] #Prints the entire week's per day expected hours
frame.iloc[start_row+increment:end_row+increment, start_col+1] #Prints the entire week's per day actual hours
print frame.iloc[start_row:end_row, start_col].iloc[-1] #Last entry in column of "Actual hours"
print frame.iloc[start_row:end_row, start_col+1].iloc[-1] #Last entry in column of "Actual hours
print 'current row...', start_row, 'coach...', allFiles[start_row/increment]
start_row=start_row+increment;
end_row = end_row + increment;
frame.iloc[start_row+increment:end_row+increment,start_col] #Prints the entire week's per day expected hours
frame.iloc[start_row+increment:end_row+increment, start_col+1] #Prints the entire week's per day actual hours
print frame.iloc[start_row:end_row, start_col].iloc[-1] #Last entry in column of "Actual hours"
print frame.iloc[start_row:end_row, start_col+1].iloc[-1] #Last entry in column of "Actual hours
print 'current row...', start_row, 'coach...', allFiles[start_row/increment]
start_row=start_row+increment;
end_row = end_row + increment;
frame.iloc[start_row+increment:end_row+increment,start_col] #Prints the entire week's per day expected hours
frame.iloc[start_row+increment:end_row+increment, start_col+1] #Prints the entire week's per day actual hours
print frame.iloc[start_row:end_row, start_col].iloc[-1] #Last entry in column of "Actual hours"
print frame.iloc[start_row:end_row, start_col+1].iloc[-1] #Last entry in column of "Actual hours
print 'current row...', start_row, 'coach...', allFiles[start_row/increment]
start_row=start_row+increment;
end_row = end_row + increment;
frame.iloc[start_row+increment:end_row+increment,start_col] #Prints the entire week's per day expected hours
frame.iloc[start_row+increment:end_row+increment, start_col+1] #Prints the entire week's per day actual hours
print frame.iloc[start_row:end_row, start_col].iloc[-1] #Last entry in column of "Actual hours"
print frame.iloc[start_row:end_row, start_col+1].iloc[-1] #Last entry in column of "Actual hours
print 'current row...', start_row, 'coach...', allFiles[start_row/increment]
start_row=start_row+increment;
end_row = end_row + increment;
frame.iloc[start_row+increment:end_row+increment,start_col] #Prints the entire week's per day expected hours
frame.iloc[start_row+increment:end_row+increment, start_col+1] #Prints the entire week's per day actual hours
print frame.iloc[start_row:end_row, start_col].iloc[-1] #Last entry in column of "Actual hours"
print frame.iloc[start_row:end_row, start_col+1].iloc[-1] #Last entry in column of "Actual hours
print 'current row...', start_row, 'coach...', allFiles[start_row/increment]
n=3; start_col=3+2*n; for start_row in range(0,156,8): print 'current row...', start_row, 'coach...', allFiles[start_row/increment] print frame.iloc[start_row:start_row+8, start_col].iloc[-1] #Last entry in column of "Actual hours" print frame.iloc[start_row:start_row+8, start_col+1].iloc[-1] #Last entry in column of "Actual hours" print "-------------------"
In [ ]: