Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

type conversion in python from float to int

Tags:

python

pandas

I am trying to change data_df which is type float64 to int.

data_df['grade'] = data_df['grade'].astype(int)

I get the following error.

invalid literal for int() with base 10: '17.44'

like image 340
john Avatar asked Nov 20 '16 17:11

john


1 Answers

From:

data_df['grade'] = data_df['grade'].astype(int)

Need to change int into 'int'

data_df['grade'] = data_df['grade'].astype('int')
like image 121
Ruperto Avatar answered Oct 18 '22 10:10

Ruperto