pandas.Series.map

Map values of Series according to input correspondence.

Used for substituting each value in a Series with another value, that may be derived from a function, a dict or a Series.

param arg
function, dict, or Series

Mapping correspondence.

param na_action
{None, ‘ignore’}, default None

If ‘ignore’, propagate NaN values, without passing them to the mapping correspondence.

return

Series Same index as caller.

Limitations

  • Series data types String is currently unsupported by Intel Scalable Dataframe Compiler.

  • arg as Series is currently unsupported by Intel Scalable Dataframe Compiler.

  • arg as function should return scalar. Other types are currently unsupported by Intel Scalable Dataframe Compiler.

  • na_action is currently unsupported by Intel Scalable Dataframe Compiler.

Examples

map() accepts a function.
import pandas as pd
from numba import njit


@njit
def series_map():
    s = pd.Series([1., 2., 3., 4., 5.])
    return s.map(lambda x: x ** 2)


print(series_map())
$ python ./series/series_map.py
0     1.0
1     4.0
2     9.0
3    16.0
4    25.0
dtype: float64

See also

Series.map

For applying more complex functions on a Series.

DataFrame.apply

Apply a function row-/column-wise.

DataFrame.applymap

Apply a function elementwise on a whole DataFrame.