Open In App

numpy.floor() in Python

Last Updated : 08 Apr, 2025
Summarize
Comments
Improve
Suggest changes
Share
1 Like
Like
Report

The numpy.floor() function returns the largest integer less than or equal to each element in the input array. It effectively rounds numbers down to the nearest whole number. Let's understand with an example:


Output
Floored: [ 0.  1.  2.  3.  4. 10.]

Explanation: np.floor() function reduces every element of the array 'a' to its floor value.

Syntax

numpy.floor(x)

Parameters:

  • x: Input array (array-like)

Return Type: Array with the floor of each element (as floats)

Examples of numpy.floor()

Example 1: With Decimal Values


Output
Input: [0.53, 1.54, 0.71]
Floored: [0. 1. 0.]

Example 2: Precise Decimal Inputs


Output
Input: [0.5538, 1.33354, 0.71445]
Floored: [0. 1. 0.]

Example 3: Mixed Whole and Decimal Numbers


Output
Input: [1.67, 4.5, 7, 9, 12]
Floored: [ 1.  4.  7.  9. 12.]

Next Article

Similar Reads