As you can see, the TransactionNo's are not unique, in other words not every entry is its own order. So I want to make a column that have a list of all items for a particular TransactionNo when Coffee was bought with that TransactionNo.
For example, on row 7(TransactionNo 5) you see coffee is bought. So I want a column that called 'extras' that puts the other items bought with TransactionNo 5 on it. So under the column 'extras', on row 7, you would see a list ['Pastry', 'Bread']. I've tried using np.where but I cannot figure this out.
TransactionNo   Items
0   1   Bread
1   2   Scandinavian
2   2   Scandinavian
3   3   Hot chocolate
4   3   Jam
5   3   Cookies
6   4   Muffin
7   5   Coffee
8   5   Pastry
9   5   Bread
I tried df['extras'] = np.where(df['Items'] == 'Coffee', x, y) but couldn't figure out what to put for x or y.
 
    