I'm trying to add each value from one column ('smoking') with another column ('sex') and put the result in a new column called 'something'. The dataset is a DataFrame called 'data'. The values in the columns 'smoking' and 'sex' are int64.
The rows of the column 'smoking' have 1 or 0. The number 1 means that the persons smoke and the number 0 means that the person doesn't smoke. In the column 'sex' have 0 and 1 too, 0 for female and 1 for male.
for index, row in data.iterrows():
data.loc[index, 'something'] = row['smoking'] + row['sex']
data
The problem is that in the column 'something' there is just number 2.0, that means even in a row of 'smoking' is 0 and in the row of 'sex' is 1, the sum in 'something' is 2.0.
I am not undestanding the error.
I'm using python 3.9.2
The dataset is in this link of kaggle: https://www.kaggle.com/andrewmvd/heart-failure-clinical-data