cudf.DataFrame.log#

DataFrame.log()#

Get the natural logarithm of all elements, element-wise.

Natural logarithm is the inverse of the exp function, so that x.log().exp() = x

Returns
DataFrame/Series/Index

Result of the element-wise natural logarithm.

Examples

>>> import cudf
>>> ser = cudf.Series([-1, 0, 1, 0.32434, 0.5, -10, 100])
>>> ser
0     -1.00000
1      0.00000
2      1.00000
3      0.32434
4      0.50000
5    -10.00000
6    100.00000
dtype: float64
>>> ser.log()
0         NaN
1        -inf
2    0.000000
3   -1.125963
4   -0.693147
5         NaN
6    4.605170
dtype: float64

log operation on DataFrame:

>>> df = cudf.DataFrame({'first': [-1, -10, 0.5],
...                      'second': [0.234, 0.3, 10]})
>>> df
   first  second
0   -1.0   0.234
1  -10.0   0.300
2    0.5  10.000
>>> df.log()
      first    second
0       NaN -1.452434
1       NaN -1.203973
2 -0.693147  2.302585

log operation on Index:

>>> index = cudf.Index([10, 11, 500.0])
>>> index
Float64Index([10.0, 11.0, 500.0], dtype='float64')
>>> index.log()
Float64Index([2.302585092994046, 2.3978952727983707,
            6.214608098422191], dtype='float64')