Hi There,
I am new to python so please be kind to me.
I am learning the substring function, so I am just trying different cases to get familiar.
I have managed to get the output for a single substring function. However when I apply multiple conditions then I get the following error. Appreciate if you guys educate me on this.
Regards,
CK
I am new to python so please be kind to me.
I am learning the substring function, so I am just trying different cases to get familiar.
I have managed to get the output for a single substring function. However when I apply multiple conditions then I get the following error. Appreciate if you guys educate me on this.
Code:
data = {'name': ['John', 'Aaron', 'Anie', 'Nancy', 'Steve'],
'Gender': ['00M00','00M00','00F00','00F00','00x00'],
'Dept': ['01MK00', '02FN00', '03LG00', '04HR00', '05DR00']}
df = pd.DataFrame(data, columns = ['name', 'Gender', 'Dept'])
df
var=[]
for i in df["Gender"]:
for x in df["Dept"]:
if i[2].lower()=='m' & x[2:4].lower()=='mk':
var.append('Male in Marketing')
elif i[2].lower()=='f' & x[2:4].lower()=='fn':
var.append('Female in Finance')
else:
var.append('Others')
[B]Error message below[/B]
File "<ipython-input-79-ff06a7e562be>", line 4
for x in df["Dept"]:
^
IndentationError: expected an indented block
CK
Comment