copy column from one column from dataframe to another R code example
Example 1: copy only some columns to new dataframe in r
new = old[['A', 'C', 'D']].copy()
Example 2: 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)