Need to split the int and string in a 'loan term column' example: '36 months', and discard the string, leaving only the int 36.
From '36 months' to 36 ' months' to 36
I have been all over the internet looking for a solution, but the search engine looks at the column title and give urls with date solutions.
def remove_months(string):
return int(string.strip(' months'))
df['term'] = df['term'].apply(remove_months)
The first two lines of code runs (do not give an error). , but the third line gives an error.
Attribute Error: 'None Type' object has no attribute 'strip'
I need to convert the string to an integer and remove the string in the column. example: From '36 months' to 36 ' months' to 36