Yes, Hello coders
I'm tring to assign value to the variable within the data frame based on another variable my data looks like:
Housing_ID Member_ID My_new_staus
1 1
1 2
1 3
1 4
1 5
2 1
2 2
3 1
3 2
3 3
what i want to assign is where the housing id equals to 1 (which is repeated) put the My_new_staus: "Valid"
I tried to apply it through this code:
for i in range (len(df['Housing_ID'])):
if df['Housing_ID'][i] == 1 :
df['My_new_staus'][i] = 'Valid'
else:
df['My_new_staus'][i] = ''
and got this message : # Similar to Index.get_value, but we do not fall back to positional KeyError: 398
the output that i want is
Housing_ID Member_ID My_new_staus
1 1 Valid
1 2 Valid
1 3 Valid
1 4 Valid
1 5 Valid
2 1
2 2
3 1
3 2
3 3