I want to add columns to the database for all the different types of movies

Viewed 29

I want to add columns to the database for all the different types of movies in which they are marked 1 if said movie corresponds to the established genre and 0 otherwise, I give an example, please i have problems when add the columns

import numpy as np
import pandas as pd
df=pd.read_csv("titles.csv",encoding='latin-1')
import ast
List_column = df['type'].apply(ast.literal_eval).explode().unique().tolist()
for column in List_column:
    df[column]=df['type'].apply(lambda x:1 if column in ast.literal_eval(x) else 0)

Database shape Expected output example

0 Answers
Related