Handling categorical data with sklearn.

I’ve used sklearn(scikit-learn) package in python. In sklearn, I cannot directly put categorical data like ‘Sex’ which has string date, ‘male’ and ‘female’. So, I have to convert string to int or something.  import pandas as pd train = pd.read_csv(‘train.csv’) for i, sex in enumerate(train.Sex):     if sex==’male’:         train.Sex[i]=1     else:         train.Sex[i]=0 This is so tiring. What is more, how can I do with more complex data which has over three. I’d like to know useful methods to handle categorial data. Thanks.


Link to Full Article: Handling categorical data with sklearn.