pandas shift columns down until value

Solutions on MaxInterview for pandas shift columns down until value by the best coders in the world

showing results for - "pandas shift columns down until value"
Federico
25 May 2019
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
Ike
28 Jul 2020
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