0

How to combine two columns in pandas?

Df= Dataframe({'num1':[1,2,3], 'num2': [4,5,6]} And result= [1,2,3,4,5,6]

27th Oct 2022, 7:50 AM
Nabanita Borkakoti
Nabanita Borkakoti - avatar
1 Answer
0
Nabanita Borkakoti you need two square brackets to insert a list into a cell. import pandas as pd df= pd.DataFrame({'num1':[[1,2,3]], 'num2': [[4,5,6]]}) df['result']= df['num1']+ df['num2'] print(df)
27th Oct 2022, 11:17 AM
Bob_Li
Bob_Li - avatar