#python code to replace the value of each cell by mean and variance
for i in range(len(df)):
for j in range(2,5):
df.iloc[i,j]=((df.iloc[i,j]-np.mean(df.iloc[i,2:]))/np.var(df.iloc[i,2:]))
My data is arranged in matrix format where j represent the observations and i represent the year as follows.
df = pd.DataFrame({'Index': ['01/01/2019', '01/02/2019', '01/03/2019'],
'descriptor':['BV','BV','BV'],
'abc': [0.8, 0.7, 0.6],
'bcd':[0.5,0.3,0.9],
'efg':[0.6,0.5,0.3]})
Output enter image description here
The correct output should be enter image description here