Last answered:

15 Jun 2023

Posted on:

10 Dec 2022

0

ValueError: Unable to parse string "10+ s" at position 0

Hi Sir,

Working through this project as you go along in your video, I noticed the errors below.

First I think I am geting mixed up with the notion of DataFrame. I have searched online for fixes but dont seem to fully understand what I am doing. According to our data, What is my dataFrame.

How do I solve the problem in the screenshot below? Are they other ways to go around this?
image.png

4 answers ( 0 marked as helpful)
Posted on:

12 Dec 2022

1

Hi Martin,

You need to replace "+ s" by blank. So the result could be: "10" so that you're able to convert this string into interger.

Posted on:

12 Dec 2022

0

Hi Thai,

I think that is exactly what I have done please see my codes below. Please if the below is wrong kindly provide the exact codes let me try and see please.

image.png

Posted on:

13 Dec 2022

0

Hi Martin,
I think the error you encounter stems from in the last two lines of your code. You can refer to the code of mine below. I hope it helps.

image.png

Posted on:

15 Jun 2023

0

loan_data['emp_length_int'] = loan_data['emp_length'].str.replace('+', '')
loan_data['emp_length_int'] = loan_data['emp_length_int'].str.replace('< 1 year',str(0))
loan_data['emp_length_int'] = loan_data['emp_length_int'].str.replace('n/a',str(0))
loan_data['emp_length_int'] = loan_data['emp_length_int'].str.replace(' years','')
loan_data['emp_length_int'] = loan_data['emp_length_int'].str.replace(' year','')

Submit an answer