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
  • 9,989
  • 4
  • 33
  • 55
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,140
  • 2
  • 12
  • 28
0

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

Example:

Int(128.2)
128