pyspark.pandas.Index.map¶
-
Index.
map
(mapper: Union[dict, Callable[[Any], Any], pandas.core.series.Series], na_action: Optional[str] = None) → pyspark.pandas.indexes.base.Index¶ Map values using input correspondence (a dict, Series, or function).
- Parameters
- mapperfunction, dict, or pd.Series
Mapping correspondence.
- na_action{None, ‘ignore’}
If ‘ignore’, propagate NA values, without passing them to the mapping correspondence.
- Returns
- appliedIndex, inferred
The output of the mapping function applied to the index.
Examples
>>> psidx = ps.Index([1, 2, 3])
>>> psidx.map({1: "one", 2: "two", 3: "three"}) Index(['one', 'two', 'three'], dtype='object')
>>> psidx.map(lambda id: "{id} + 1".format(id=id)) Index(['1 + 1', '2 + 1', '3 + 1'], dtype='object')
>>> pser = pd.Series(["one", "two", "three"], index=[1, 2, 3]) >>> psidx.map(pser) Index(['one', 'two', 'three'], dtype='object')