My dataframe df
looks like this, the ID
column is a list.
Name Title ID
ED HHH [11111, 11112, 11113, 11114]
AD BBB [11119, 11133]
I want to first convert column ID
to a string, since I'm assuming that is how I would want the column to move on to the next step. Next step would be to basically opposite of a pivot table the dataframe df
to look like below.
I would like my dataframe df
to look like this
Name Title ID
ED HHH 11111
ED HHH 11112
ED HHH 11113
ED HHH 11114
AD BBB 11119
AD BBB 11133
I've tried
df['ID'] = df['ID'].str.split(', ')
df['ID'] = df['ID'].str.join(map(str,df['ID']))
df['ID'] = str(df['ID']).strip(', ')
df['ID'] = ''.join(str(x) for x in df['ID'])
and it does not give me what I'm looking for or it uses up too much RAM and locks my computer.
Any help or tips? Do I even have to convert the list to a string first to put it in my desired output?