ValueError: invalid literal for int() with base 10: ‘Female’

Issue

This Content is from Stack Overflow. Question asked by Stata_user

I am trying to find the mistake in 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'



Solution

This question is not yet answered, be the first one who answer using the comment. Later the confirmed answer will be published as the solution.

This Question and Answer are collected from stackoverflow and tested by JTuto community, is licensed under the terms of CC BY-SA 2.5. - CC BY-SA 3.0. - CC BY-SA 4.0.

people found this article helpful. What about you?