pandas shift columns up until value

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

showing results for - "pandas shift columns up until value"
Federico
23 Nov 2018
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