I have a DataFrame:
APPLICATION COUNT K3_Code_Sender K3_Code_Receiver TWO
0 BCCTBL_2 0.0 0 287 x
1 BDLSMF01 0.0 9996 0 x
2 BEX00003 0.0 762 0 x
3 BEX01910 711762.0 762 0 x
4 BEX02955 60.0 0 287 x
5 BEX02970 12058.0 762 387 x
6 BEX03148 179.0 0 0 x
after following iterate and if statement(row[4] = row['TWO'], its like this just to check column position)
for index, row in df_fin_k.iterrows():
if row['K3_Code_Sender'] != '0' and row['K3_Code_Receiver'] != '0':
df_fin_k.at[index, row[4]] = 2
else:
df_fin_k.at[index, row['TWO']] = 1
i get new column instead of seting values to TWO column:
APPLICATION COUNT K3_Code_Sender K3_Code_Receiver TWO x
0 BCCTBL_2 0.0 0 287 x 1.0
1 BDLSMF01 0.0 9996 0 x 1.0
2 BEX00003 0.0 762 0 x 1.0
3 BEX01910 711762.0 762 0 x 1.0
4 BEX02955 60.0 0 287 x 1.0
5 BEX02970 12058.0 762 387 x 2.0
6 BEX03148 179.0 0 0 x 1.0
How to fix this so we would have:
APPLICATION COUNT K3_Code_Sender K3_Code_Receiver TWO
0 BCCTBL_2 0.0 0 287 1.0
1 BDLSMF01 0.0 9996 0 1.0
2 BEX00003 0.0 762 0 1.0
3 BEX01910 711762.0 762 0 1.0
4 BEX02955 60.0 0 287 1.0
5 BEX02970 12058.0 762 387 2.0
6 BEX03148 179.0 0 0 1.0
Aucun commentaire:
Enregistrer un commentaire