Skip to content
geeksforgeeks
  • Courses
    • DSA to Development
    • Get IBM Certification
    • Newly Launched!
      • Master Django Framework
      • Become AWS Certified
    • For Working Professionals
      • Interview 101: DSA & System Design
      • Data Science Training Program
      • JAVA Backend Development (Live)
      • DevOps Engineering (LIVE)
      • Data Structures & Algorithms in Python
    • For Students
      • Placement Preparation Course
      • Data Science (Live)
      • Data Structure & Algorithm-Self Paced (C++/JAVA)
      • Master Competitive Programming (Live)
      • Full Stack Development with React & Node JS (Live)
    • Full Stack Development
    • Data Science Program
    • All Courses
  • Tutorials
    • Data Structures & Algorithms
    • ML & Data Science
    • Interview Corner
    • Programming Languages
    • Web Development
    • CS Subjects
    • DevOps And Linux
    • School Learning
  • Practice
    • Build your AI Agent
    • GfG 160
    • Problem of the Day
    • Practice Coding Problems
    • GfG SDE Sheet
  • Contests
    • Accenture Hackathon (Ending Soon!)
    • GfG Weekly [Rated Contest]
    • Job-A-Thon Hiring Challenge
    • All Contests and Events
  • Numpy exercise
  • pandas
  • Matplotlib
  • Data visulisation
  • EDA
  • Machin Learning
  • Deep Learning
  • NLP
  • Data science
  • ML Tutorial
  • Computer Vision
  • ML project
Open In App
Next Article:
numpy.floor_divide() in Python
Next article icon

numpy.floor() in Python

Last Updated : 08 Apr, 2025
Comments
Improve
Suggest changes
Like Article
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:

Python
import numpy as np  a = [0.5, 1.5, 2.5, 3, 4.5, 10.1]  res = np.floor(a) print("Floored:", res) 

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

Python
import numpy as np  a = [0.53, 1.54, 0.71] print("Input:", a)  res = np.floor(a) print("Floored:", res) 

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

Example 2: Precise Decimal Inputs

Python
import numpy as np  a = [0.5538, 1.33354, 0.71445] print("Input:", a)  res = np.floor(a) print("Floored:", res) 

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

Example 3: Mixed Whole and Decimal Numbers

Python
import numpy as np  a = [1.67, 4.5, 7, 9, 12] print("Input:", a)  res = np.floor(a) print("Floored:", res) 

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


Next Article
numpy.floor_divide() in Python
author
mohit gupta_omg :)
Improve
Article Tags :
  • Python
  • Python numpy-Mathematical Function
  • Python-numpy
Practice Tags :
  • python

Similar Reads

  • numpy.floor_divide() in Python
    numpy.floor_divide(arr1, arr2, /, out = None, where = True, casting = 'same_kind', order = 'K', dtype = None) : Array element from first array is divided by the elements from second array(all happens element-wise). Both arr1 and arr2 must have same shape. It is equivalent to the Python // operator a
    3 min read
  • numpy.clip() in Python
    numpy.clip() function is used to Clip (limit) the values in an array. Given an interval, values outside the interval are clipped to the interval edges. For example, if an interval of [0, 1] is specified, values smaller than 0 become 0, and values larger than 1 become 1. Syntax : numpy.clip(a, a_min,
    2 min read
  • NumPy Array in Python
    NumPy (Numerical Python) is a powerful library for numerical computations in Python. It is commonly referred to multidimensional container that holds the same data type. It is the core data structure of the NumPy library and is optimized for numerical and scientific computation in Python. Table of C
    2 min read
  • numpy.gcd() in Python
    numpy.gcd(arr1, arr2, out = None, where = True, casting = ‘same_kind’, order = ‘K’, dtype = None) : This mathematical function helps user to calculate GCD value of |arr1| and |arr2| elements. Greatest Common Divisor (GCD) of two or more numbers, which are not all zero, is the largest positive number
    1 min read
  • numpy.around() in Python
    numpy.around(arr, decimals = 0, out = None) : This mathematical function helps user to evenly round array elements to the given number of decimals. Parameters : array : [array_like] Input array. decimal : [int, optional] Decimal places we want to round off. Default = 0. In case of -ve decimal, it sp
    2 min read
  • Python | Numpy ndarray.__ifloordiv__()
    With the help of Numpy ndarray.__ifloordiv__(), we can divide a particular value that is provided as a parameter in the ndarray.__ifloordiv__() method. Value will be divided to each and every element in a numpy array and remember it always gives the floor value after division. Syntax: ndarray.__iflo
    1 min read
  • numpy.greater() in Python
    The numpy.greater() checks whether x1 is greater than x2 or not. Syntax : numpy.greater(x1, x2[, out]) Parameters : x1, x2 : [array_like]Input arrays. If x1.shape != x2.shape, they must be broadcastable to a common shape out : [ndarray, boolean]Array of bools, or a single bool if x1 and x2 are scala
    2 min read
  • numpy.bincount() in Python
    In an array of +ve integers, the numpy.bincount() method counts the occurrence of each element. Each bin value is the occurrence of its index. One can also set the bin size accordingly. Syntax : numpy.bincount(arr, weights = None, min_len = 0) Parameters : arr : [array_like, 1D]Input array, having p
    2 min read
  • numpy.mod() in Python
    numpy.mod() is another function for doing mathematical operations in numpy.It returns element-wise remainder of division between two array arr1 and arr2 i.e. arr1 % arr2 .It returns 0 when arr2 is 0 and both arr1 and arr2 are (arrays of) integers. Syntax : numpy.mod(arr1, arr2, /, out=None, *, where
    2 min read
  • numpy.fromiter() function – Python
    NumPy's fromiter() function is a handy tool for creating a NumPy array from an iterable object. This iterable can be any Python object that provides elements one at a time. The function is especially useful when you need to convert data from a custom data source, like a file or generator, into a Num
    2 min read
geeksforgeeks-footer-logo
Corporate & Communications Address:
A-143, 7th Floor, Sovereign Corporate Tower, Sector- 136, Noida, Uttar Pradesh (201305)
Registered Address:
K 061, Tower K, Gulshan Vivante Apartment, Sector 137, Noida, Gautam Buddh Nagar, Uttar Pradesh, 201305
GFG App on Play Store GFG App on App Store
Advertise with us
  • Company
  • About Us
  • Legal
  • Privacy Policy
  • In Media
  • Contact Us
  • Advertise with us
  • GFG Corporate Solution
  • Placement Training Program
  • Languages
  • Python
  • Java
  • C++
  • PHP
  • GoLang
  • SQL
  • R Language
  • Android Tutorial
  • Tutorials Archive
  • DSA
  • Data Structures
  • Algorithms
  • DSA for Beginners
  • Basic DSA Problems
  • DSA Roadmap
  • Top 100 DSA Interview Problems
  • DSA Roadmap by Sandeep Jain
  • All Cheat Sheets
  • Data Science & ML
  • Data Science With Python
  • Data Science For Beginner
  • Machine Learning
  • ML Maths
  • Data Visualisation
  • Pandas
  • NumPy
  • NLP
  • Deep Learning
  • Web Technologies
  • HTML
  • CSS
  • JavaScript
  • TypeScript
  • ReactJS
  • NextJS
  • Bootstrap
  • Web Design
  • Python Tutorial
  • Python Programming Examples
  • Python Projects
  • Python Tkinter
  • Python Web Scraping
  • OpenCV Tutorial
  • Python Interview Question
  • Django
  • Computer Science
  • Operating Systems
  • Computer Network
  • Database Management System
  • Software Engineering
  • Digital Logic Design
  • Engineering Maths
  • Software Development
  • Software Testing
  • DevOps
  • Git
  • Linux
  • AWS
  • Docker
  • Kubernetes
  • Azure
  • GCP
  • DevOps Roadmap
  • System Design
  • High Level Design
  • Low Level Design
  • UML Diagrams
  • Interview Guide
  • Design Patterns
  • OOAD
  • System Design Bootcamp
  • Interview Questions
  • Inteview Preparation
  • Competitive Programming
  • Top DS or Algo for CP
  • Company-Wise Recruitment Process
  • Company-Wise Preparation
  • Aptitude Preparation
  • Puzzles
  • School Subjects
  • Mathematics
  • Physics
  • Chemistry
  • Biology
  • Social Science
  • English Grammar
  • Commerce
  • World GK
  • GeeksforGeeks Videos
  • DSA
  • Python
  • Java
  • C++
  • Web Development
  • Data Science
  • CS Subjects
@GeeksforGeeks, Sanchhaya Education Private Limited, All rights reserved
We use cookies to ensure you have the best browsing experience on our website. By using our site, you acknowledge that you have read and understood our Cookie Policy & Privacy Policy
Lightbox
Improvement
Suggest Changes
Help us improve. Share your suggestions to enhance the article. Contribute your expertise and make a difference in the GeeksforGeeks portal.
geeksforgeeks-suggest-icon
Create Improvement
Enhance the article with your expertise. Contribute to the GeeksforGeeks community and help create better learning resources for all.
geeksforgeeks-improvement-icon
Suggest Changes
min 4 words, max Words Limit:1000

Thank You!

Your suggestions are valuable to us.

What kind of Experience do you want to share?

Interview Experiences
Admission Experiences
Career Journeys
Work Experiences
Campus Experiences
Competitive Exam Experiences