we have the following data
Name genres
A Action|Adventure|Science Fiction|Thriller
B Action|Adventure|Science Fiction|Thriller
C Adventure|Science Fiction|Thriller
I want the data such that my data frame is
Name genres
A Action
A Adventure
A Science Fiction
A Thriller
B Action
B Adventure
B Science Fiction
B Thriller
C Adventure
C Science Fiction
C Thriller
here is my code
gen = df1[df1['genres'].str.contains('|')]
gen1 = gen.copy()
gen2 = gen.copy()
gen3 = gen.copy()
gen4 = gen.copy()
gen1['genres'] = gen1['genres'].apply(lambda x: x.split("|")[0])
gen2['genres'] = gen2['genres'].apply(lambda x: x.split("|")[1])
gen3['genres'] = gen3['genres'].apply(lambda x: x.split("|")[2])
gen4['genres'] = gen4['genres'].apply(lambda x: x.split("|")[3])
I am getting the error
IndexError: list index out of range