I read csv file in pandas Dataframe and then get its dummy and concat them, but for example I Have column named "Genre" and it contains "comedy, drama" and "action, comedy" so when I get dummy and concat them it makes a object for each sentence but I want parse them.for example I want to makes object 'Genre.comedy' , 'Genre.Drama', 'Genre.action' instead of 'Genre.comedy,drama' and 'Genre.action,comedy' Here is my code:
import numpy as np
import pandas as pd
import matplotlib.pyplot as plt
import csv
from sklearn import preprocessing
trainset = pd.read_csv("/Users/yada/Downloads/IMDBMovieData.csv", encoding='latin-1')
X = trainset.drop(['Description', 'Runtime'], axis=1)
features = ['Genre','Actors']
for f in features:
X_dummy = pd.get_dummies(X[f], prefix = f)
X = X.drop([f], axis = 1)
X = pd.concat((X, X_dummy), axis = 1)
and this is the some row of my csv file: csv