Answers for "pandas new column from others"

1

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
Posted by: Guest on May-07-2021

Code answers related to "pandas new column from others"

Python Answers by Framework

Browse Popular Code Answers by Language