Search
 
SCRIPT & CODE EXAMPLE
 

PYTHON

pandas copy data from a column to another

df = pd.DataFrame()

df['X'] = [0, 3, 1, 1, 2, 2, 3, 3, 1, 2]
df['Y'] = [111.0, np.nan, np.nan, 112, 113, np.nan, 114, 115, np.nan, 116]

df['Y'] = df['Y'].fillna(df['X'])

print(df)
Comment

pandas copy column to another columns if null

df['performance_l'] = df['performance_l'].fillna(df['performance_r'])
Comment

PREVIOUS NEXT
Code Example
Python :: how to run terminal commands in python 
Python :: userregisterform 
Python :: python create venv 
Python :: python find difference between lists 
Python :: slug url 
Python :: python dictionary sort 
Python :: get a list as input from user 
Python :: Python NumPy split Function Example 
Python :: pytorch transpose 
Python :: finding path of a module in python 
Python :: create empty numpy array without shape 
Python :: django response headers 
Python :: embed image in html from python 
Python :: python dictionary dynamic key 
Python :: tkinter window size 
Python :: turn list in to word python 
Python :: python 3.8.5 download 32 bit 
Python :: how to create a variable in python 
Python :: print font size python 
Python :: np.arange and np.linspace difference 
Python :: how to sort a list descending python 
Python :: python while false loop 
Python :: convert 2d string array to float python 
Python :: connect a mean value to histogram pandas 
Python :: edit pandas row value 
Python :: how to read panda column 
Python :: pandas merge df 
Python :: how to make a checksum to a file python 
Python :: open tar file pandas 
Python :: python trim whitespace from end of string 
ADD CONTENT
Topic
Content
Source link
Name
6+2 =