xarray.CFTimeIndex.map#
- CFTimeIndex.map(mapper, na_action=None)[source]#
Map values using an input mapping or function.
- Parameters:
- Returns:
Union[Index,MultiIndex]– 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.
See also
Index.whereReplace values where the condition is False.
Examples
>>> idx = pd.Index([1, 2, 3]) >>> idx.map({1: "a", 2: "b", 3: "c"}) Index(['a', 'b', 'c'], dtype='str')
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='str')
>>> idx = pd.Index(["a", "b", "c"]) >>> idx.map(lambda x: x.upper()) Index(['A', 'B', 'C'], dtype='str')