I have a dataframe that ask for the Unique value and I will like to get another column based on those unique value.
Trying to get the colour in all_names
raw_data={'Class':['A1','B1','C1','D1','A1'],
'Name':['Harry','Christabel','Mel','Chris','Cherry'],
'Color':['Red','Blue','Pink','Red','Red']}
df = pd.DataFrame(raw_data)
all_names = df['Name'][df['Class']=='A1'].unique()
all_colour=df.loc[df['Colour'].isin(all_names)]
I have tried the code above but I am trying to get the color for Harry and Cherry which is red and red.