import pandas as pd
data_list = [['Name', 'Fruit'],
['Abel', 'Apple'],
['Abel', 'Pear'],
['Abel', 'Coconut'],
['Abel', 'Pear'],
['Benny', 'Apple'],
['Benny', 'Apple'],
['Cain', 'Apple'],
['Cain', 'Coconut'],
['Cain', 'Pear'],
['Cain', 'Lemon'],
['Cain', 'Orange']]
record_df = pd.DataFrame(data_list[1:], columns = data_list[0])
I am trying to create another DataFrame to tell me if someone has the same fruit.
Expected Output:
Name | Repeated_Fruits
Abel | 1
Benny| 1
Cain | 0
I have tried
bool_series = record_df.duplicated(subset=['Name'], keep=False)
record_df_2 = record_df[~bool_series]
But everything is True. What am I missing?