Having a data frame as below:
data = {'Name':['Mathew', 'Mathew', 'Mathew', 'Mathew','Mathew','John','John','John'],
'Age':[12,12, 12,13, 13,12,13,13],
'Colour':['Yellow','Blue','Yellow','green','blue','pink','black','brown']}
df = pd.DataFrame(data)
df
I tried a loop as below. I need the unique value in based on the loop. Like, Name is mathew and age is 12, mylist contain the values yellow and blue.
for j in set(df.Name):
for i in set(df.Age):
#my_list=list of unique colour produced in according to each loop
print(i,j)
output of above code will be as follows:
12 John
13 John
12 Mathew
13 Mathew
But what i want as output is,df.Name is mathew and df.age is 12, then mylist will be as follows: my_list=['yellow','blue']