.log() function returns an element-wise natural logarithm of an array.
.log() returns an
ndarray with each element as the natural logarithm of the corresponding element in
The following example creates a
ndarray and applies
.log() to it:
import numpy as npnd = np.array([[1,2.71828],[2.71828,1]])print(nd)print(np.log(nd))
This produces the following output:
[[1. 2.71828][2.71828 1. ]][[0. 0.99999933][0.99999933 0. ]]
Interested in helping build Docs? Read the Contribution Guide or share your thoughts in this feedback form.
Learn Python:NumPy on Codecademy
Data Scientist: Machine Learning SpecialistMachine Learning Data Scientists solve problems at scale, make predictions, find patterns, and more! They use Python, SQL, and algorithms.
Includes 27 Courses
With Professional Certification