I have a code to normalise data imported from xls. which is a s follows
import numpy as np
Xt, Tt = XLSImport('AI_sample.xlsx')
# calculate the maximum values
valX1_max = np.max((Xt)[0])
valX2_max = np.max((Xt)[1])
valX3_max = np.max((Xt)[2])
valX4_max = np.max((Xt)[3])
valX5_max = np.max((Xt)[4])
valX6_max = np.max((Xt)[5])
valX7_max = np.max((Xt)[6])
valX8_max = np.max((Xt)[7])
valT1_max = np.max((Tt)[0])
valT2_max = np.max((Tt)[1])
print valX1_max, valX2_max, valX3_max, valX4_max, valX5_max, valX6_max, valX7_max, valX8_max, valT1_max, valT2_max
# normalize data
Xt[0] /= valX1_max
Xt[1] /= valX2_max
Xt[2] /= valX3_max
Xt[3] /= valX4_max
Xt[4] /= valX5_max
Xt[5] /= valX6_max
Xt[6] /= valX7_max
Xt[7] /= valX8_max
Tt[0] /= valT1_max
Tt[1] /= valT2_max
print Xt, Tt
This is a rather simple code where, Xt and Tt are sets of data. The dimensions of Xt is (750, 8) where 750 is number of rows and 8 is the number of columns and dimensions of Tt is (750, 2) the numbers corresponding to rows and columns as above. The data is being normalised for each column based on the maximum value in that particular column.
Now I want to create a function and create a loop so that I dont want to repeat the same code over and over again as done in my example. How do i do that? i am new to programming and i am not that familiar with looping concepts. thank u in advance
I want to have something like:
func norm(param):
val_max = []
for i in range(num_rows):
#and the normalization inside this block
how should i do this?