Extract seperated value from columns
Try:
# Create an example dataframe
df = pd.DataFrame({&quot;genres&quot;:[&quot;Fantasy|Sci-Fi&quot;,
                &quot;Action|Adventure|Fantasy&quot;,
                &quot;Thriller&quot;,
                &quot;Action|Adventure|Thriller|bbv&quot;,&quot;Action&quot;,&quot;Action|Adventure|thriller&quot;]})

# Get a dataframe with as many columns as there are genres
df = df.genres.str.get_dummies(sep = &quot;|&quot;)

# Get the genres as values
df = df.multiply(df.columns)

# Rename the columns to have the genre id
df.columns = [&quot;genre_&quot; + str(x) for x in range(len(df.columns))]

Input:

Output:

EDIT:
you can simply use pandas assign method:
df.assign(genre1= df.genres.str.split(&quot;|&quot;, expand = True).iloc[:,:1],
          genre2 = df.genres.str.split(&quot;|&quot;, expand = True).iloc[:,1:2])

*Output: