Convert float to integer to get number without dot and zero [duplicate]

27
February 03, 2019, at 4:30 PM

This question already has an answer here:

  • Python float to int conversion 5 answers

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

Answer 1

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.

Answer 2

Use int(), Like this:

>>int(2.4)
2
>>int(4.0)
4
Answer 3

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

Example:

Int(128.2)
128
READ ALSO
remove an animation iteration event listener to animated child node

remove an animation iteration event listener to animated child node

SCENARIO: I have a top/parent <div> that has an infinite CSS animation on itIt also has some <div> as sub/child nodes and some (one or more) might have as well an infinite CSS animation on them

43
android.view.InflateException: Binary XML file line #2: Binary XML file line #2: Error inflating class android.support.v4.widget.DrawerLayout

android.view.InflateException: Binary XML file line #2: Binary XML file line #2: Error inflating class android.support.v4.widget.DrawerLayout

I experienced this error while working on an android food ordering app in android studio 33:

32
data is not inserted correctly in csv

data is not inserted correctly in csv

When i add data into csv programmatically it gives me below issue:

32
how to convert php values to json encode please check example below

how to convert php values to json encode please check example below

how to convert php array values to json encode,we can ignore numeric(price) values

26