Search
 
SCRIPT & CODE EXAMPLE
 

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
Comment

pandas shift columns down until value

#We create a shift down method so that we can have all the preious summed values in the bottom index and hence
#deleting them would be easy 
def shift_down(data):
    i=0
    while(i<len(data.columns)):
        while(pd.isnull(data.iloc[len(data.index)-1,i])==True):
            data.iloc[:,i] = data.iloc[:, i].shift(1)
        i+=1
    return data
Comment

PREVIOUS NEXT
Code Example
Python :: pandas get column names with nan 
Python :: how to use python to sleep if the user is not using the system 
Python :: initialize array of natural numbers python 
Python :: python read string from file 
Python :: boxplot pandas 
Python :: blender python get selected object 
Python :: chart-studio python install 
Python :: TinyDB 
Python :: python print char n times 
Python :: python trace table generator 
Python :: all alphanumeric characters for python python 
Python :: python add 0 before number 
Python :: find number of common element in two python array 
Python :: python test if you can convert to int 
Python :: plotly update legend title 
Python :: python file location path 
Python :: django staff_member_required decorator 
Python :: how to count range in django template 
Python :: display video in jupyter notebook 
Python :: selectfield flask wtf 
Python :: python write list to file 
Python :: change tensor type pytorch 
Python :: list of prime numbers in python with list comprehension 
Python :: 2d array pytho 
Python :: how to uninstall python idle on ubuntu 
Python :: display youtube video in jupyter notebook 
Python :: multiple inputs in python 
Python :: how to import model_to_dict 
Python :: declare numpy zeros matrix python 
Python :: python replace all values in a column 
ADD CONTENT
Topic
Content
Source link
Name
6+6 =