modin.pandas.Series.map¶
- Series.map(arg: Callable | Mapping | Series, na_action: Literal['ignore'] | None = None) Series[source] (https://github.com/snowflakedb/snowpark-python/blob/v1.23.0/src/snowflake/snowpark/modin/plugin/extensions/series_overrides.py#L998-L1008)¶
- 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 a- Series.- 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 to- NaN. However, if the dictionary is a- dictsubclass that defines- __missing__(i.e. provides a method for default values), then this default is used rather than- NaN.- Examples - >>> s = pd.Series(['cat', 'dog', np.nan, 'rabbit']) >>> s 0 cat 1 dog 2 None 3 rabbit dtype: object - mapaccepts a- dictor a- Series. Values that are not found in the- dictare converted to- NaN, unless the dict has a default value (e.g.- defaultdict):- >>> s.map({'cat': 'kitten', 'dog': 'puppy'}) 0 kitten 1 puppy 2 None 3 None dtype: object - It also accepts a function: - >>> s.map('I am a {}'.format) 0 I am a cat 1 I am a dog 2 I am a <NA> 3 I am a rabbit dtype: object - To avoid applying the function to missing values (and keep them as - NaN)- na_action='ignore'can be used:- >>> s.map('I am a {}'.format, na_action='ignore') 0 I am a cat 1 I am a dog 2 None 3 I am a rabbit dtype: object - Note that in the above example, the missing value in Snowflake is NULL, it is mapped to - Nonein a string/object column.