Skip to content
Advertisement

how to convert decimal to integer without rounding the decimal in python?

i am having one DataFrame as shown below,i want to convert the decimal number to integer without rounding.

JavaScript

Desired output:

JavaScript

Advertisement

Answer

Option 1

One way to do that is to cast to the type int as follows

JavaScript

Option 2

One can also do it with .applymap() as follows

JavaScript

Or using custom lambda functions

JavaScript

Option 3

Another way is using .apply() with a custom lambda function

JavaScript
User contributions licensed under: CC BY-SA
1 People found this is helpful
Advertisement