modin.pandas.Series.map¶
- Series.map(arg: Callable | Mapping | Series, na_action: Literal['ignore'] | None = None) Series[source]¶
Map values of Series according to an input mapping or function.
Used for substituting each value in a Series with another value, that may be derived from a function, a
dictor aSeries.- Parameters:
arg (function, collections.abc.Mapping subclass or Series) – Mapping correspondence.
na_action ({None, 'ignore'}, default None) – If ‘ignore’, propagate NULL values, without passing them to the mapping correspondence. Note that, it will not bypass NaN values in a FLOAT column in Snowflake.
- Returns:
Same index as caller.
- Return type:
See also
Series.apply: 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.Notes
When
argis a dictionary, values in Series that are not in the dictionary (as keys) are converted toNaN. However, if the dictionary is adictsubclass that defines__missing__(i.e. provides a method for default values), then this default is used rather thanNaN.Examples
mapaccepts adictor aSeries. Values that are not found in thedictare converted toNaN, unless the dict has a default value (e.g.defaultdict):It also accepts a function:
To avoid applying the function to missing values (and keep them as
NaN)na_action='ignore'can be used:Note that in the above example, the missing value in Snowflake is NULL, it is mapped to
Nonein a string/object column.