1

I have two columns:

Data = {'Col1': [1 , 2 , 3 , 0 , 0 , 4] , 'Col2': [0 , 2 , 0 , 5 , 6 , 4]}
df = pd.DataFrame(data = Data)
df.head()

Col1    Col2
0   1    0
1   2    2
2   3    0
3   0    5
4   0    6
5   4    4

I want to create a third column which combines these two, but does not add the cells. I want a dataset like the following:

Col1    Col2    Col3
0   1    0    1
1   2    2    2
2   3    0    3
3   0    5    5
4   0    6    6
5   4    4    4

I've simply added the two columns, but this solution adds the values existing in both columns. The solution is probably very easy, but i couldn't wrap my head around it...

Thanks in advance!

New Dev
  • 48,427
  • 12
  • 87
  • 129
Amby95
  • 67
  • 6

0 Answers0