pandas shift columns up until value

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

we are a community of more than 2 million smartest coders
registration for
employee referral programs
are now open
get referred to google, amazon, flipkart and more
register now
  
pinned-register now
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