I have a dataframe that has the following structure:
First_Name  Last_Name  Group_Membership
Joe         Francis    A
Jane        Davis      B
Mary        Smith      A,B,C
Ian         Brown      A
I need transform the values in the cell Group_Membership into columns and get a dataframe that looks like this:
First_Name  Last_Name  A    B    C
Joe         Francis    Yes  No   No
Jane        Davis      No   Yes  No
Mary        Smith      Yes  Yes  Yes
Ian         Brown      Yes  No   No
I managed to convert the values in the column Group_Membership into list and then 'exploding' it, but then I should somehow transpose it
df.['Group_Membership'] = df.['Group_Membership'].str.split(',')
df.explode('Group_Membership')
Somehow now I should be pivoting it. Also, I'm not sure this is the best way to do it...
Your help would be greatly appreciated!
 
     
    