I have a dataframe with a column called Age, which I am trying to convert to numeric. One of the values in the column is text "seven". How do I get this done using Python, so that the text gets converted to number 7? Am looking at an option where I don't need to loop through each row and convert on a case basis. Please help
            Asked
            
        
        
            Active
            
        
            Viewed 2,287 times
        
    1 Answers
0
            
            
        One option is to hardcode a list containing ['zero', 'one', 'two'] up to highest age. Then you can get the index based on the number from the database.
 >>>number = ['zero', 'one', 'two', 'three', 'four', 'five', 'six', 'seven']
 >>>index = number.index('seven')
 >>>print(index)
 7
See this example.
        ronald kok
        
- 38
 - 7