I have a dataframe that looks like the following:
publication_title authors type ...
title 1 ['author1', 'author2', 'author3'] proceedings
title 2 ['author4', 'author5'] collections
title 3 ['author6', 'author7'] books
.
.
.
What I want to do is take the column 'authors' and split the list inside it into several rows by duplicating all the other columns, and I want also to store the results in a new column named: 'author' and keep the original column.
The following depicts exactly what I want to achieve:
publication_title authors author type ...
title 1 ['author1', 'author2', 'author3'] author1 proceedings
title 1 ['author1', 'author2', 'author3'] author2 proceedings
title 1 ['author1', 'author2', 'author3'] author3 proceedings
title 2 ['author4', 'author5'] author4 collections
title 2 ['author4', 'author5'] author5 collections
title 3 ['author6', 'author7'] author6 books
title 3 ['author6', 'author7'] author7 books
.
.
.
I have tried to achieve this using pandas DataFrame explode method but I cannot find a way to store the results in a new column.
Thanks for the help.