Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR PYTHON

pandas new column from others

import pandas as pd

#Here a and b are existing columns

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 #column
ADD COMMENT
Topic
Name
5+4 =