xorbits.pandas.Index.map#
- Index.map(mapper, na_action=None, dtype=None, memory_scale=None, skip_infer=False)#
Map values using an input mapping or function.
- Parameters
mapper (function, dict, or Series) – Mapping correspondence.
na_action ({None, 'ignore'}) – If ‘ignore’, propagate NA values, without passing them to the mapping correspondence.
- Returns
The output of the mapping function applied to the index. If the function returns a tuple with more than one element a MultiIndex will be returned.
- Return type
Union[Index, MultiIndex]
Examples
>>> idx = pd.Index([1, 2, 3]) >>> idx.map({1: 'a', 2: 'b', 3: 'c'}) Index(['a', 'b', 'c'], dtype='object')
Using map with a function:
>>> idx = pd.Index([1, 2, 3]) >>> idx.map('I am a {}'.format) Index(['I am a 1', 'I am a 2', 'I am a 3'], dtype='object')
>>> idx = pd.Index(['a', 'b', 'c']) >>> idx.map(lambda x: x.upper()) Index(['A', 'B', 'C'], dtype='object')
- dtypenp.dtype, default None
Specify return type of the function. Must be specified when we cannot decide the return type of the function.
- memory_scalefloat
Specify the scale of memory uses in the function versus input size.
- skip_infer: bool, default False
Whether infer dtypes when dtypes or output_type is not specified
This docstring was copied from pandas.core.indexes.base.Index.