I want to set the value of a column(Z) in a pandas dataframe based on the values in other columns (X,Y):
Here is a sample code for that:
for i, row in df.iterrows():
#print(i, row['Z'])
if row['X'] == 1 and row['Y'] == 0:
row['Z'] = 1
if row['X'] == 0 and row['Y'] == 1:
row['Z'] = 0
if row['X'] == 0 and row['Y'] == 0:
row['Z'] = 2
if row['X'] == 1 and row['Y'] == 1:
row['Z'] = 3
what is the way to do so?