NumPy Tutorial NumPy Statistics NumPy References

NumPy - floor() function



The NumPy floor() function returns the floor value of the input data. The floor of the scalar x is the largest integer i, such that i <= x.

Syntax

numpy.floor(a, out=None)

Parameters

a Required. Specify array (array_like) containing elements, of which the floor value is calculated.
out Optional. Specify a location into which the result is stored. If provided, it must have a shape that the inputs broadcast to. If not provided or None, a freshly-allocated array is returned.

Return Value

Returns the floor value of each element of a.

Example:

In the example below, numpy floor() function is used to calculate the floor value of each element present in array Arr.

import numpy as np

Arr = np.array([0.65, 6.56, 52.67, 167.23])
print("Original Array:")
print(Arr)

print("\nFloor value array:")
print(np.floor(Arr))

The output of the above code will be:

Original Array:
[   0.65    6.56   52.67  167.23]

Floor value array:
[   0.    6.   52.  167.]

❮ NumPy - Functions