, na_action=None) Series[source]#

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.

argfunction, subclass or Series

Mapping correspondence.

na_action{None, ‘ignore’}, default None

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


Same index as caller.


>>> s = cudf.Series(['cat', 'dog', np.nan, 'rabbit'])
>>> s
0      cat
1      dog
2     <NA>
3   rabbit
dtype: object

map accepts a dict or a Series. Values that are not found in the dict are converted to NaN, default values in dicts are currently not supported.:

>>>{'cat': 'kitten', 'dog': 'puppy'})
0   kitten
1    puppy
2     <NA>
3     <NA>
dtype: object

It also accepts numeric functions:

>>> s = cudf.Series([1, 2, 3, 4, np.nan])
>>> x: x ** 2)
0       1
1       4
2       9
3       16
4     <NA>
dtype: int64

Pandas Compatibility Note

Please note map currently only supports fixed-width numeric type functions.