I am using this script to get the interpolation values from the excel. It is working fine and giving fine results
import pandas as pd
from pandas import ExcelWriter
from pandas import ExcelFile
import numpy as np
def estimateMonthlySales(domainId,categoryId,salesRank):
df = pd.read_excel('data.xlsx', sheetname='units')
df = df.set_index('index')
indexRef = str(domainId)+'_'+str(categoryId)
startCol = 7
array_x1 = df.loc[indexRef,:].index
array_y1 = df.loc[indexRef,:].values
array_x = []
for i in range(startCol,len(array_x1)):
array_x.append(int(array_x1[i]))
array_y = []
for i in range(startCol,len(array_y1)):
try:
j = int(array_y1[i])
except:
pass
array_y.append(j)
#print(array_x)
#print(array_y)
return(int(np.interp(salesRank, array_x, array_y)*0.98))
print(estimateMonthlySales(2,468292,600))
I am using numpy interp function. But i want to write my own interpolate function to get the similar results for my dataset as provided by numpy interpolation functoin. How can i write my own interpolation function without use of numpy and pandas.?
I am using Python 3.6.