1#We create a shift down method so that we can have all the preious summed values in the bottom index and hence
2#deleting them would be easy
3def shift_down(data):
4 i=0
5 while(i<len(data.columns)):
6 while(pd.isnull(data.iloc[len(data.index)-1,i])==True):
7 data.iloc[:,i] = data.iloc[:, i].shift(1)
8 i+=1
9 return data
1#We create a function to shift up the data of each column up until the first actual number
2def shift_up(data):
3 i=0
4 while(i<len(data.columns)):
5 while(pd.isnull(data.iloc[0,i])==True):
6 data.iloc[:,i]=data.iloc[:,i].shift(-1)
7 i+=1
8 return data