I am trying to convert a string variable into an integer (0,1) for (Female, Male). I get the following error for my code:
import pandas as pd
data = [[2012, 'Female'], [2013, 'Male'], [2014, 'Female']]
df = pd.DataFrame(data, columns=['year', 'sex'])
df.sex=df.sex.astype("int64")
This is the error I receive:
ValueError: invalid literal for int() with base 10: 'Female'