Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR PYTHON

pandas shift columns up until value

#We create a function to shift up the data of each column up until the first actual number
def shift_up(data):
    i=0
    while(i<len(data.columns)):
        while(pd.isnull(data.iloc[0,i])==True):
            data.iloc[:,i]=data.iloc[:,i].shift(-1)
        i+=1
    return data
 
PREVIOUS NEXT
Tagged: #pandas #shift #columns
ADD COMMENT
Topic
Name
8+2 =