How to convert object to int in jupyter (pandas)?
dataset['Gender'] = dataset['Gender'].astype(str).astype(int)
CodePudding user response:
You have a couple of options, you can map the values using a dictionary or a can factorize all unique values.
dataset['Gender'].str.lower().map({'female':0, 'male':1})
# assuming you have only male and female.
dataset['Gender'] = dataset['Gender'].factorize()[0]