Project - Automatic Forecast Tool

My most recent project was creating a python script that would take data from an excel spreadsheet and use a time series analysis algorithm: EWMA(Estimated Weight Moving Average) The sheet is capable of processing aprox 3000 rows of data in 30 seconds!, prior to this, it would take one week to process the data.

Sample code below:

def returnvalue(rowNum): #create an array of dates vs sales
df = pd.DataFrame([sheet.cell(row = rowNum, column = P12).value, sheet.cell(row = rowNum, column = P11).value,
    sheet.cell(row = rowNum, column = P10).value, sheet.cell(row = rowNum, column = P9).value,
    sheet.cell(row = rowNum, column = P8).value, sheet.cell(row = rowNum, column = P7).value,
    sheet.cell(row = rowNum, column = P6).value, sheet.cell(row = rowNum, column = P5).value,
    sheet.cell(row = rowNum, column = P4).value, sheet.cell(row = rowNum, column = P3).value,
    sheet.cell(row = rowNum, column = P2).value, sheet.cell(row = rowNum, column = P1).value,
    sheet.cell(row = rowNum, column = P0).value, 0, 0, 0
], index = dates, columns = ['Actual Sales'])# import last 12 months sales into an array

# CURRENT MONTH
if df['Actual Sales'].iloc[12] < df['Actual Sales'].iloc[1]: df['Actual Sales'].iloc[12] = df['Actual Sales'].iloc[1]#
if WIP is less than sales last year then use last year 's figures instead for our estimation#
MONTH + 1
df['Actual Sales'].iloc[13] = df['Actual Sales'].iloc[2]# month + 1 = prev value at that point in time# MONTH + 2
df['Actual Sales'].iloc[14] = df['Actual Sales'].iloc[3]# month + 2 = prev value at that point in time# MONTH + 3
df['Actual Sales'].iloc[15] = df['Actual Sales'].iloc[4]# month + 3 = prev value at that point in time

df['EWMA'] = pd.ewma(df['Actual Sales'], span = 13)# Forecast Values using EWMA(estimated weight moving average)

## ADJUST VALUES ACORDING TO THE EWMA
df['Actual Sales'].iloc[12] = df['EWMA'].iloc[12]

df['Actual Sales'].iloc[13] = df['EWMA'].iloc[13]# month + 1 = value estimated by EWMA algorithm at this point in time# MONTH + 2
df['Actual Sales'].iloc[14] = df['EWMA'].iloc[14]# month + 2 = value estimated by EWMA algorithm at this point in time# MONTH + 3
df['Actual Sales'].iloc[15] = df['EWMA'].iloc[15]# month + 3 = value estimated by EWMA algorithm at this point in time

predictednet = sheet.cell(row = rowNum, column = NetStock).value - (df['Actual Sales'].iloc[13] + df['Actual Sales'].iloc[14])# Current Net Stock - Month 1 and Month 2 demand

if debug: df.plot(title = sheet.cell(row = rowNum, column = StockCode).value)

# find out averages / forecasts e.t.c# work out ammount to order# update sheet


return predictednet# how much stock would we have
if we sold this and next months stock(helps us estimate how much we need to replen)