Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR PYTHON

pandas dataframe add column from another column

import pandas as pd

df = pd.DataFrame({'a':[1,2], 'b':[3,4]})
df['c'] = df.apply(lambda row: row.a + row.b, axis=1)
df
#    a  b  c
# 0  1  3  4
# 1  2  4  6
Source by stackoverflow.com #
 
PREVIOUS NEXT
Tagged: #pandas #dataframe #add #column #column
ADD COMMENT
Topic
Name
6+9 =