TypeError: '<' not supported between instances of 'str' and 'int' | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

TypeError: '<' not supported between instances of 'str' and 'int'

I ran the below command - print(np.unique(cars_data['Doors'])) Output - ['2' '3' '4' '5' 'five' 'four' 'three'] Then i ran below commands cars_data['Doors'].replace('three',3,inplace=True) cars_data['Doors'].replace('four',4,inplace=True) cars_data['Doors'].replace('five',5,inplace=True) And then whne i tried to print values again by - print(np.unique(cars_data['Doors'])) I am getting error.

11th Apr 2020, 6:00 PM
Himanshu Jain
Himanshu Jain - avatar
1 Answer
0
I have got the answer myself. We need to explicitly convert datatype to int64. And then i am getting the desired output. cars_data['Doors']=cars_data['Doors'].astype('int64')
11th Apr 2020, 6:18 PM
Himanshu Jain
Himanshu Jain - avatar