How do I print/return the value based on values from another column?
df = my_df[['Index', 'FRUITS']]
print(df)
Index FRUITS
7 Green Apple
7 Mango
7 Orange
7 Strawberry
9 Pineapple
9 Banana
9 Grapes
10 Orange (Unripe)
10 Plum
L = ['apple', 'orange']
Here, I want to check if the string Apple or Orange are present in the substring for every Index irrespective of case, return those serial numbers where either one of these 2 fruits aren't found!
I tried using approaches from different answers and tried groupby and iterating over fruits:
out = df.groupby('Index')['FRUITS'].apply(lambda x: L in x)
TypeError: 'in <string>' requires string as left operand, not list
So, the expected output is:
[9, 10]