- 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 base 10 logarithm of the input array element-wise in Numpy
To return the base 10 logarithm of the input array, element-wise, use the numpy.log10() method in Python Numpy. For real-valued input data types, log10 always returns real output. For each value that cannot be expressed as a real number or infinity, it yields nan and sets the invalid floating point error flag.
Returns the logarithm to the base 10 of x, element-wise. NaNs are returned where x is negative. 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
Create an array using the array() method −
arr = np.array([1e-15, 10000])
Display the array −
print("Array...
", arr)
Get the type of the array −
print("
Our Array type...
", arr.dtype)
Get the dimensions of the Array −
print("
Our Array Dimension...
",arr.ndim)
Get the shape of the Array −
print("
Our Array Shape...
",arr.shape)
To return the base 10 logarithm of the input array, element-wise, use the numpy.log10() method. For real-valued input data types, log10 always returns real output. For each value that cannot be expressed as a real number or infinity, it yields nan and sets the invalid floating point error flag −
print("
Result...
",np.log10(arr))
Example
import numpy as np # Create an array using the array() method arr = np.array([1e-15, 10000]) # Display the array print("Array...
", arr) # Get the type of the array print("
Our Array type...
", arr.dtype) # Get the dimensions of the Array print("
Our Array Dimension...
",arr.ndim) # Get the shape of the Array print("
Our Array Shape...
",arr.shape) # To return the base 10 logarithm of the input array, element-wise, use the numpy.logaddexp() method in Python Numpy # For real-valued input data types, log10 always returns real output. # For each value that cannot be expressed as a real number or infinity, # it yields nan and sets the invalid floating point error flag. print("
Result...
",np.log10(arr))
Output
Array... [1.e-15 1.e+04] Our Array type... float64 Our Array Dimension... 1 Our Array Shape... (2,) Result... [-15. 4.]