- Data Structure
- Networking
- RDBMS
- Operating System
- Java
- MS Excel
- iOS
- HTML
- CSS
- Android
- Python
- C Programming
- C++
- C#
- MongoDB
- MySQL
- Javascript
- PHP
- Physics
- Chemistry
- Biology
- Mathematics
- English
- Economics
- Psychology
- Social Studies
- Fashion Studies
- Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
Return the floor of the input in Numpy
To return the floor of the input, use the numpy.floor() method in Python Numpy. The floor of the scalar x is the largest integer i, such that i <= x. It is often denoted as $\mathrm{\lfloor X \rfloor}$. The function returns the floor of each element in x. This is a scalar if x is a scalar.
The out is 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. A tuple (possible only as a keyword argument) must have length equal to the number of outputs.
Steps
At first, import the required library −
import numpy as np
To return the floor of the input, use the numpy.floor() method in Python Numpy.
Check floor() for float −
print("Result? ", np.floor(45.7)) print("
Result? ", np.floor(-487.4))
Check floor() for inf −
print("
Result? ", np.floor(-np.inf))
Check floor() for nan and inf −
print("
Result? ", np.floor(np.nan)) print("
Result? ", np.floor(np.inf))
Check floor() for log −
print("
Result? ", np.floor(np.log(1))) print("
Result? ", np.floor(np.log(2)))
Example
import numpy as np # To return the floor of the input, use the numpy.floor() method in Python Numpy print("Returning the floor value...
") # Check floor() for float print("Result? ", np.floor(45.7)) print("
Result? ", np.floor(-487.4)) # Check floor() for inf print("
Result? ", np.floor(-np.inf)) # Check floor() for nan and inf print("
Result? ", np.floor(np.nan)) print("
Result? ", np.floor(np.inf)) # Check floor() for log print("
Result? ", np.floor(np.log(1))) print("
Result? ", np.floor(np.log(2)))
Output
Returning the floor value... Result? 45.0 Result? -488.0 Result? -inf Result? nan Result? inf Result? 0.0 Result? 0.0