0

Can any one please to tell me how to round float to integer ? I tried with np.round() on pred_y, I get dot zero like 12.0 for example and not 12 without dot zero, in python

Thank you for your helping

3 Answers3

0

Use int(), Like this:

>>int(2.4)
2
>>int(4.0)
4
Mehrdad Pedramfar
  • 10,941
  • 4
  • 38
  • 59
0

If you are dealing with numpy array you can do the following

y = np.array(np.round(x), dtype=int)

However if its just a number int(round(x)) will do the job.

xashru
  • 3,400
  • 2
  • 17
  • 30
0

for convert float to int you just have to use int() function.

Example:

Int(128.2)
128